#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<int> g[N];
int to[N];
int cnt[N];
int lvl[N];
int dfs(int u) {
  to[u] = -1;
  if (g[u].empty()) {
    return u;
  }
  int beg = -1;
  int last = -1;
  for (int v : g[u]) {
    lvl[v] = lvl[u] + 1;
    int tmp = dfs(v);
    if (last == -1) {
      last = tmp;
      beg = v;
    } else if (lvl[tmp] < lvl[last]) {
      to[tmp] = beg;
      cnt[beg] += lvl[tmp] - lvl[u];
      beg = v;
    } else {
      to[last] = v;
      cnt[v] += lvl[last] - lvl[u];
      last = tmp;
    }
  }
  to[u] = beg;
  return last;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    g[p].push_back(i);
  }
  dfs(0);
  for (int u = 0; u != -1; u = to[u]) {
    printf("%d ", u);
  }
  printf("\n");
  printf("%d\n", accumulate(cnt, cnt + n, 0));
  for (int u = 0; u != -1; u = to[u]) {
    for (int i = 0; i < cnt[u]; i++) {
      printf("%d ", u);
    }
  }
  printf("\n");
}
