#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
vector<int> son[maxn];
int f[maxn];
int dep[maxn];
bool cmp(int x, int y) { return dep[x] < dep[y]; }
void find_lon(int u) {
  if (son[u].size() == 0) {
    dep[u] = 1;
    return;
  }
  int sz = son[u].size();
  int mx = 0;
  for (int i = 0; i < sz; i++) {
    int v = son[u][i];
    find_lon(v);
    mx = max(mx, dep[v]);
  }
  dep[u] = mx + 1;
  sort(son[u].begin(), son[u].end(), cmp);
}
vector<int> ans, op;
void solve(int u) {
  ans.push_back(u);
  int sz = son[u].size();
  int v;
  for (int i = 0; i < sz; i++) {
    v = son[u][i];
    solve(v);
    if (i == 0) continue;
    for (int j = 1; j <= dep[son[u][i - 1]]; j++) op.push_back(v);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x;
    son[x].push_back(i);
    f[i] = x;
  }
  find_lon(0);
  solve(0);
  for (auto u : ans) cout << u << " ";
  cout << endl;
  cout << op.size() << endl;
  for (auto u : op) cout << u << " ";
  cout << endl;
}
