#include <bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,sse4,sse4.1")
using namespace std;
using ll = int64_t;
const long long maxn = 1 << 17, mod = 1000000007;
long long n, h[maxn], pref[maxn], p[maxn];
vector<long long> g[maxn], ord;
void find(long long v) {
  for (auto &i : g[v]) {
    find(i);
    if (h[i] + 1 > h[v]) {
      h[v] = h[i] + 1;
      pref[v] = i;
    }
  }
  ord.push_back(v);
}
int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n;
  for (long long i = 1; i < n; i++) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  find(0);
  bitset<maxn> uwu;
  long long T = 0;
  do {
    uwu[T] = 1;
    T = pref[T];
  } while (T);
  for (long long i = 0; i < n; i++) pref[i] *= uwu[i];
  reverse(begin(ord), end(ord));
  vector<long long> ops;
  for (auto i : ord)
    if (i && pref[p[i]] != i) {
      long long t = pref[p[i]];
      pref[p[i]] = i;
      pref[i] = t;
      p[t] = i;
      ops.push_back(t);
    }
  reverse(begin(ops), end(ops));
  long long t = 0;
  while (pref[t]) t++;
  ord.clear();
  while (true) {
    ord.push_back(t);
    if (t)
      t = p[t];
    else
      break;
  }
  reverse(begin(ord), end(ord));
  for (auto &i : ord) cout << i << " ";
  cout << '\n';
  cout << ops.size() << '\n';
  for (auto i : ops) cout << i << " ";
  cout << '\n';
}
