#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int n, pre[maxn], son[maxn], dep[maxn], Ans[maxn], cnt, lis[maxn];
vector<int> g[maxn];
int main() {
  scanf("%d", &n);
  dep[1] = 1;
  for (int i = 1; i < n; i++) {
    scanf("%d", &pre[i + 1]);
    pre[i + 1]++;
    g[pre[i + 1]].push_back(i + 1);
    son[pre[i + 1]]++;
    dep[i + 1] = dep[pre[i + 1]] + 1;
  }
  int p = 1;
  for (int i = 2; i <= n; i++)
    if (dep[i] > dep[p]) p = i;
  int from = p;
  cnt = 0;
  int lim = n - dep[p];
  for (int i = 1; i <= lim; i++) {
    while (pre[p] && son[pre[p]] <= 1) p = pre[p];
    if (!pre[p]) break;
    Ans[++cnt] = p;
    int f = pre[p];
    pre[p] = 0;
    while (pre[g[f].back()] != f) g[f].pop_back();
    pre[p] = g[f].back();
    g[pre[p]].push_back(p);
    son[pre[p]]++;
    son[f]--;
  }
  int lcnt = 0;
  p = from;
  lis[++lcnt] = p;
  while (pre[p]) {
    lis[++lcnt] = pre[p];
    p = pre[p];
  }
  for (int i = lcnt; i >= 1; i--) printf("%d ", lis[i] - 1);
  puts("");
  printf("%d\n", cnt);
  for (int i = cnt; i >= 1; i--) {
    int x = Ans[i] - 1;
    printf("%d ", x);
  }
  puts("");
  return 0;
}
