#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    ;
  int x = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    x = x * 10 + ch - '0';
  return x;
}
const int N = 1e5 + 5;
int n, fa[N], dep[N], mx[N];
vector<int> son[N], p, q;
void dfs(int x) {
  mx[x] = dep[x];
  for (int y : son[x]) {
    dep[y] = dep[x] + 1;
    dfs(y);
    mx[x] = max(mx[x], mx[y]);
  }
}
bool cmp(int x, int y) { return mx[x] < mx[y]; }
void calc(int x) {
  sort(son[x].begin(), son[x].end(), cmp);
  p.push_back(x);
  int la = 0;
  for (int y : son[x]) {
    calc(y);
    for (int i = 1; i <= la; i++) q.push_back(y);
    la = mx[y] - dep[x];
  }
}
int main() {
  n = read();
  for (int i = 2; i <= n; i++) {
    fa[i] = read() + 1;
    son[fa[i]].push_back(i);
  }
  dep[1] = 1;
  dfs(1);
  calc(1);
  for (int x : p) printf("%d ", x - 1);
  puts("");
  printf("%d\n", q.size());
  for (int x : q) printf("%d ", x - 1);
  puts("");
  return 0;
}
