#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
inline void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      f = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
struct note {
  int t;
  int next;
};
int cnt;
int head[N];
note e[N << 1];
inline void add(int x, int y) {
  e[++cnt].t = y;
  e[cnt].next = head[x];
  head[x] = cnt;
}
int n, m;
int fa[N];
int max_son[N];
int max_dep[N];
int dep[N], ind[N];
void dfs(int p) {
  ind[++m] = p;
  for (int i = head[p]; i + 1; i = e[i].next) {
    int t = e[i].t;
    if (t != max_son[p]) {
      dfs(t);
    }
  }
  if (max_son[p]) {
    dfs(max_son[p]);
  }
}
int main() {
  read(n);
  memset(head, -1, sizeof(head));
  for (int i = 2; i <= n; i++) {
    int x;
    read(x);
    x++;
    fa[i] = x;
    add(x, i);
    dep[i] = dep[x] + 1;
  }
  for (int i = n; i > 1; i--) {
    if (max_dep[i] + 1 >= max_dep[fa[i]]) {
      max_dep[fa[i]] = max_dep[i] + 1;
      max_son[fa[i]] = i;
    }
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    printf("%d ", ind[i] - 1);
  }
  printf("\n");
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    ans += dep[ind[i - 1]] - dep[fa[ind[i]]];
  }
  printf("%d\n", ans);
  for (int i = 2; i <= n; i++) {
    for (int j = dep[ind[i - 1]] - dep[fa[ind[i]]]; j; j--) {
      printf("%d ", ind[i] - 1);
    }
  }
  return 0;
}
