#include <bits/stdc++.h>
using namespace std;
int n, p[100005];
vector<int> edge[100005];
vector<int> ans;
vector<int> ord;
int dep[100005], num[100005];
multiset<pair<int, int> > dp[100005];
int lazy[100005];
int last[100005];
void dfs(int v, int u) {
  if (u == -1)
    dep[v] = 0;
  else
    dep[v] = dep[u] + 1;
  int sz = -1;
  int to = -1;
  int sum = 0;
  for (int i = 0; i < edge[v].size(); i++) {
    dfs(edge[v][i], v);
    if (sz < (int)dp[edge[v][i]].size()) {
      sz = (int)dp[edge[v][i]].size();
      to = edge[v][i];
    }
    sum += (*dp[edge[v][i]].begin()).first + lazy[edge[v][i]];
  }
  if (sz == -1) {
    dp[v].insert(pair<int, int>(dep[v], v));
    return;
  }
  lazy[to] = lazy[to] + sum - (*dp[to].begin()).first - lazy[to];
  map<int, int> M;
  for (int i = 0; i < edge[v].size(); i++) {
    if (edge[v][i] == to) continue;
    int sum2 = sum - (*dp[edge[v][i]].begin()).first - lazy[edge[v][i]];
    for (auto A : dp[edge[v][i]]) {
      int val = A.first + lazy[edge[v][i]] + sum2;
      int ver = A.second;
      M[ver] = edge[v][i];
      dp[to].insert(pair<int, int>(val - lazy[to], ver));
    }
  }
  swap(dp[v], dp[to]);
  swap(lazy[v], lazy[to]);
  int las = (*dp[v].begin()).second;
  if (M.find(las) == M.end())
    last[v] = to;
  else
    last[v] = M[las];
  return;
}
bool L[100005];
void make(int v) {
  while (v != 0) {
    L[v] = 1;
    v = p[v];
  }
}
void dfs1(int v, int u) {
  num[v] = ord.size();
  ord.push_back(v);
  bool ex = 0;
  for (int i = 0; i < edge[v].size(); i++) {
    if (L[edge[v][i]]) ex = 1;
  }
  if (ex) {
    for (int i = 0; i < edge[v].size(); i++) {
      if (!L[edge[v][i]]) dfs1(edge[v][i], v);
    }
    for (int i = 0; i < edge[v].size(); i++) {
      if (L[edge[v][i]]) dfs1(edge[v][i], v);
    }
  } else {
    for (int i = 0; i < edge[v].size(); i++) {
      if (last[v] == edge[v][i]) continue;
      dfs1(edge[v][i], v);
    }
    if (last[v] != -1) dfs1(last[v], v);
  }
}
void dfs2(int v, int u) {
  bool ex = 0;
  for (int i = 0; i < edge[v].size(); i++) {
    if (L[edge[v][i]]) ex = 1;
  }
  if (ex) {
    for (int i = 0; i < edge[v].size(); i++) {
      if (!L[edge[v][i]]) {
        dfs2(edge[v][i], v);
        int x = ord[num[edge[v][i]] - 1];
        for (int C = 0; C < dep[x] - dep[v]; C++) ans.push_back(edge[v][i]);
      }
    }
    for (int i = 0; i < edge[v].size(); i++) {
      if (L[edge[v][i]]) {
        dfs2(edge[v][i], v);
        int x = ord[num[edge[v][i]] - 1];
        for (int C = 0; C < dep[x] - dep[v]; C++) ans.push_back(edge[v][i]);
      }
    }
  } else {
    for (int i = 0; i < edge[v].size(); i++) {
      if (last[v] == edge[v][i]) continue;
      {
        dfs2(edge[v][i], v);
        int x = ord[num[edge[v][i]] - 1];
        for (int C = 0; C < dep[x] - dep[v]; C++) ans.push_back(edge[v][i]);
      }
    }
    if (last[v] != -1) {
      dfs2(last[v], v);
      int x = ord[num[last[v]] - 1];
      for (int C = 0; C < dep[x] - dep[v]; C++) ans.push_back(last[v]);
    }
  }
}
int main() {
  memset(last, -1, sizeof(last));
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x;
    cin >> x;
    edge[x].push_back(i + 1);
    p[i + 1] = x;
  }
  dfs(0, -1);
  int mx = 10000000;
  int L = -1;
  set<int> S;
  for (auto A : dp[0]) {
    S.insert(A.first);
    if (mx > A.first - dep[A.second]) {
      mx = A.first - dep[A.second];
      L = A.second;
    }
  }
  assert(S.size() == 1);
  make(L);
  dfs1(0, -1);
  dfs2(0, -1);
  for (int i = 0; i < n; i++) cout << ord[i] << '\n';
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << '\n';
}
