#include <bits/stdc++.h>
using namespace std;
int const N = 100000 + 1;
int n, dp[N];
vector<int> g[N];
void dfs(int u) {
  dp[u] = 0;
  for (auto v : g[u]) {
    dfs(v);
    dp[u] = max(dp[u], 1 + dp[v]);
  }
}
vector<int> ext, ans, op;
void calc(int u) {
  while (ext.size()) {
    op.push_back(u);
    ext.pop_back();
  }
  ans.push_back(u);
  vector<pair<int, int> > vc;
  for (auto v : g[u]) vc.push_back(make_pair(dp[v], v));
  sort(vc.begin(), vc.end());
  for (auto v : vc) {
    calc(v.second);
  }
  ext.push_back(u);
}
int main() {
  cin >> n;
  for (int p, i = 1; i < n; ++i) {
    scanf("%d", &p);
    g[p].push_back(i);
  }
  dfs(0);
  calc(0);
  for (int i = 0; i < ans.size(); ++i) {
    if (i > 0) printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
  cout << op.size() << endl;
  for (int i = 0; i < op.size(); ++i) {
    if (i > 0) printf(" ");
    printf("%d", op[i]);
  }
  puts("");
  return 0;
}
