#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
vector<int> t[N], ans, temp;
int d[N], f[N], child[N], cnt;
void dfs(int v) {
  ans.push_back(v);
  for (int i = 1; i <= cnt; i++) temp.push_back(v);
  cnt = 0;
  for (auto u : t[v])
    if (u != child[v]) dfs(u);
  if (child[v]) dfs(child[v]);
  cnt++;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> f[i];
    t[f[i]].push_back(i);
    d[i] = d[f[i]] + 1;
  }
  int v = max_element(d, d + n) - d;
  while (v) {
    child[f[v]] = v;
    v = f[v];
  }
  dfs(0);
  for (auto u : ans) cout << u << " ";
  cout << endl << temp.size() << endl;
  for (auto u : temp) cout << u << " ";
  cout << endl;
}
