#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct edge {
  int v, nxt;
} g[N << 1];
int tot = 0, head[N];
inline void add(int u, int v) {
  g[++tot] = edge{v, head[u]};
  head[u] = tot;
}
int n, fa[N], dep[N], mxdep[N];
inline void dfs(int u) {
  mxdep[u] = dep[u];
  for (int i = head[u]; i; i = g[i].nxt) {
    int v = g[i].v;
    dep[v] = dep[u] + 1;
    dfs(v);
    mxdep[u] = max(mxdep[u], mxdep[v]);
  }
}
int stk[N], top;
inline void solve(int u) {
  printf("%d ", u);
  int x = -1;
  int cnt = 0;
  for (int i = head[u]; i; i = g[i].nxt) {
    if (x == -1 || mxdep[g[i].v] > mxdep[x]) x = g[i].v;
    ++cnt;
  }
  if (x == -1) return;
  if (cnt == 1) {
    solve(x);
    return;
  }
  int pre = x;
  for (int i = head[u]; i; i = g[i].nxt) {
    int v = g[i].v;
    if (v == x) continue;
    stk[++top] = pre;
    add(v, pre);
    mxdep[pre]++;
    mxdep[v] = max(mxdep[v], mxdep[pre]);
    pre = v;
  }
  solve(pre);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) scanf("%d", &fa[i]), add(fa[i], i);
  dfs(0);
  solve(0);
  printf("\n%d\n", top);
  for (int i = top; i >= 1; --i) printf("%d ", stk[i]);
  return 0;
}
