#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1000000007;
long double EPS = 1e-9;
long long binpow(long long b, long long p, long long mod) {
  long long ans = 1;
  b %= mod;
  for (; p; p >>= 1) {
    if (p & 1) ans = ans * b % mod;
    b = b * b % mod;
  }
  return ans;
}
void pre() {}
vector<vector<long long> > g;
long long sz[100100];
long long ht[100100];
long long seq[100100];
long long label[100100];
vector<long long> mover;
void dsz(int nn) {
  sz[nn] = 1;
  ht[nn] = 1;
  for (auto v : g[nn]) {
    dsz(v);
    (ht[nn] = max((ht[nn]), (1 + ht[v])));
    sz[nn] += sz[v];
  }
}
int treeend = 0;
void dfs(int nn, int rightmost = 1) {
  label[treeend] = nn;
  treeend++;
  sort((g[nn]).begin(), (g[nn]).end(),
       [&](int a, int b) { return ht[a] < ht[b]; });
  for (int i = 0; i < g[nn].size(); i++) {
    if (i == (long long)(g[nn]).size() - 1) {
      dfs(g[nn][i], rightmost);
    } else {
      dfs(g[nn][i], 0);
    }
  }
  if (!rightmost) {
    mover.emplace_back(treeend);
  }
}
void solve() {
  long long n;
  cin >> n;
  g.resize(n);
  for (long long i = 1; i <= n - 1; ++i) {
    long long x;
    cin >> x;
    g[x].emplace_back(i);
  }
  dsz(0);
  dfs(0, 1);
  for (long long i = 0; i <= n - 1; ++i) {
    cout << label[i] << " ";
  }
  cout << '\n';
  cout << mover.size() << '\n';
  for (auto v : mover) {
    cout << label[v] << " ";
  }
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  pre();
  long long _t = 1;
  for (long long i = 1; i <= _t; i++) {
    solve();
  }
}
