#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 0;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ '0');
  if (f) return x;
  return -x;
}
const int N = 1e5;
struct Edge {
  int v, nxt;
} e[(N << 1) + 3];
int fe[N + 3];
int fa[N + 3];
int mxd[N + 3];
int hvs[N + 3];
vector<int> id;
vector<int> opt;
int n, en, cnt;
void addedge(int u, int v) {
  en++;
  e[en].v = v;
  e[en].nxt = fe[u];
  fe[u] = en;
}
void dfs1(int u) {
  for (int i = fe[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa[u]) continue;
    dfs1(v);
    if (mxd[v] + 1 > mxd[u]) {
      mxd[u] = mxd[v] + 1, hvs[u] = v;
    }
  }
}
void dfs2(int u) {
  id.push_back(u);
  for (int i = 1; i <= cnt; i++) opt.push_back(u);
  cnt = 0;
  for (int i = fe[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa[u] || v == hvs[u]) continue;
    dfs2(v);
  }
  if (hvs[u]) {
    dfs2(hvs[u]);
  }
  cnt++;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    fa[i]++;
    addedge(fa[i], i);
    addedge(i, fa[i]);
  }
  dfs1(1);
  dfs2(1);
  for (int i = 0; i < id.size(); i++) printf("%d ", id[i] - 1);
  puts("");
  printf("%d\n", opt.size());
  for (int i = 0; i < opt.size(); i++) printf("%d ", opt[i] - 1);
  puts("");
  return 0;
}
