#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1e9 + 7;
long long INF = 1e18;
const int N = 200000;
set<long long> gr[N];
long long h[N];
long long dfs(long long v, long long pr) {
  h[v] = h[pr] + 1;
  long long nw = v;
  for (auto i : gr[v]) {
    long long vv = dfs(i, v);
    if (h[vv] > h[nw]) {
      nw = vv;
    }
  }
  return nw;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),
      cout << fixed << setprecision(20);
  long long n;
  cin >> n;
  vector<long long> p(n);
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    gr[p[i]].insert(i);
  }
  long long ls = dfs(0, 0);
  long long ls2 = ls;
  vector<long long> ans;
  while (ls != 0) {
    while (ls != 0 && gr[p[ls]].size() <= 1) {
      ls = p[ls];
    }
    if (ls == 0) {
      break;
    }
    long long u = 0;
    auto it = gr[p[ls]].begin();
    if (*it != ls) {
      u = *it;
    } else {
      it++;
      u = *it;
    }
    ans.push_back(ls);
    gr[p[ls]].erase(ls);
    gr[u].insert(ls);
    p[ls] = u;
  }
  vector<long long> tr;
  while (ls2 != 0) {
    tr.push_back(ls2);
    ls2 = p[ls2];
  }
  tr.push_back(0);
  reverse(tr.begin(), tr.end());
  reverse(ans.begin(), ans.end());
  for (auto i : tr) cout << i << " ";
  cout << "\n" << ans.size() << "\n";
  for (auto i : ans) {
    cout << i << " ";
  }
}
