#include <bits/stdc++.h>
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
int p[N], h[N];
int n;
vector<int> g[N], ans, ord;
void calc(int v) {
  h[v] = 1;
  for (int to : g[v]) {
    calc(to);
    h[v] = max(h[v], h[to] + 1);
  }
}
void dfs(int v) {
  ord.push_back(v);
  int last = 0;
  for (int to : g[v]) {
    for (int j = 1; j <= last; j++) ans.push_back(to);
    dfs(to);
    last = h[to];
  }
}
bool comp(int a, int b) { return h[a] < h[b]; }
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    scanf("%d", &p[i]);
    g[p[i]].push_back(i);
  }
  calc(0);
  for (int i = 0; i < n; i++) sort(g[i].begin(), g[i].end(), comp);
  dfs(0);
  for (int out : ord) printf("%d ", out);
  printf("\n%d\n", ans.size());
  for (int out : ans) printf("%d ", out);
}
