#include <bits/stdc++.h>
inline long long read() {
  long long x = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || '9' < c; c = getchar())
    if (c == '-') f = -1;
  for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
inline void write(long long x) {
  static char buf[20];
  int len = 0;
  if (x < 0) putchar('-'), x = -x;
  for (; x; x /= 10) buf[len++] = x % 10 + '0';
  if (!len)
    putchar('0');
  else
    while (len) putchar(buf[--len]);
}
inline void writesp(long long x) {
  write(x);
  putchar(' ');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
int fir[200010], fa[200010], dep[200010], h[200010];
std::vector<int> son[200010];
int ans[200010];
int n;
int cmp(int x, int y) { return h[x] < h[y]; }
int main() {
  n = read();
  dep[0] = 0;
  fa[0] = -1;
  for (int i = 1; i < n; i++) {
    fa[i] = read();
    dep[i] = dep[fa[i]] + 1;
    son[fa[i]].push_back(i);
  }
  for (int i = n - 1; i >= 0; i--) {
    h[i] = 1;
    for (int j : son[i]) h[i] = std::max(h[i], h[j] + 1);
  }
  for (int i = 0; i < n; i++) std::sort(son[i].begin(), son[i].end(), cmp);
  int now = 0, tot = 0;
  while (son[now].size()) now = son[now].back();
  while (~fa[now]) {
    if (son[fa[now]].size() == 1) {
      now = fa[now];
      continue;
    }
    ans[++tot] = now;
    son[fa[now]].pop_back();
    fa[now] = son[fa[now]].back();
    son[fa[now]].push_back(now);
  }
  now = 0;
  for (int i = 1; i < n; i++) {
    writesp(now);
    now = son[now][0];
  }
  writeln(now);
  writeln(tot);
  for (int i = tot; i; i--) writesp(ans[i]);
  putchar('\n');
  return 0;
}
