#include <bits/stdc++.h>
using namespace std;
int a[100001][2];
int ls[100001];
int fa[100001];
int nx[100001];
int Ans[100001];
bool bz[100001];
int d[100001];
int n, i, j, k, l, len, ans, tot, tot2, mx, mx2, h, t;
void New(int x, int y) {
  ++len;
  a[len][0] = y;
  a[len][1] = ls[x];
  ls[x] = len;
}
void dfs(int t, int d) {
  int i;
  if (d > mx) mx = d, mx2 = t;
  for (i = ls[t]; i; i = a[i][1]) fa[a[i][0]] = t, dfs(a[i][0], d + 1);
}
int main() {
  scanf("%d", &n);
  for (i = 2; i <= n; i++) {
    scanf("%d", &fa[i]);
    ++fa[i];
    New(fa[i], i);
  }
  dfs(1, 1);
  while (mx2) {
    bz[mx2] = 1;
    nx[fa[mx2]] = mx2;
    mx2 = fa[mx2];
  }
  for (j = 1; j <= n; j++)
    if (bz[j]) {
      for (i = ls[j]; i; i = a[i][1])
        if (!bz[a[i][0]]) d[++t] = a[i][0];
    }
  while (h < t) {
    ++h;
    j = nx[fa[d[h]]];
    for (i = ls[d[h]]; i; i = a[i][1]) d[++t] = a[i][0];
    fa[j] = d[h];
    nx[fa[d[h]]] = d[h];
    nx[d[h]] = j;
    Ans[++tot] = j;
  }
  for (i = 1; i; i = nx[i]) printf("%d ", i - 1);
  printf("\n");
  printf("%d\n", tot);
  for (i = tot; i >= 1; i--) printf("%d ", Ans[i] - 1);
}
