#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 998244353;
const ll root = 3;
ll binpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
ll modInv(ll a) { return binpow(a, MOD - 2); }
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
ll arr[mxN];
vector<int> adj[mxN];
ll dp[mxN];
int mxd[mxN];
int depth[mxN];
int n;
int par[mxN];
int np[mxN];
vector<int> ans;
vector<int> ord;
int prv = -1;
int dfs_sz(int u) {
  mxd[u] = depth[u];
  for (int v : adj[u]) {
    depth[v] = depth[u] + 1;
    mxd[u] = max(mxd[u], dfs_sz(v));
  }
  return mxd[u];
}
void dfs(int u) {
  np[u] = prv;
  ord.push_back(u);
  prv = u;
  while (np[u] != par[u]) {
    np[u] = np[np[u]];
    ans.push_back(u);
  }
  for (int v : adj[u]) dfs(v);
}
int main() {
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin.tie(0)->sync_with_stdio(0);
  cin >> n;
  par[0] = -1;
  for (int i = (1); i < (n); ++i) {
    cin >> par[i];
    adj[par[i]].push_back(i);
  }
  dfs_sz(0);
  for (int i = (0); i < (n); ++i) {
    sort(adj[i].begin(), adj[i].end(),
         [&](int a, int b) { return mxd[a] < mxd[b]; });
  }
  dfs(0);
  for (int i = (0); i < (n); ++i) {
    cout << ord[i] << " ";
  }
  cout << "\n";
  cout << ans.size() << "\n";
  for (int i = (0); i < (ans.size()); ++i) {
    cout << ans[i] << " ";
  }
  return 0;
}
