#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
int n, fa[maxn], dep[maxn], son[maxn], cnt;
vector<int> g[maxn], id, mov;
void dfs(int x) {
  id.push_back(x);
  for (int i = (1); i <= (cnt); ++i) mov.push_back(x);
  cnt = 0;
  for (auto v : g[x])
    if (v != son[x]) dfs(v);
  if (son[x]) dfs(son[x]);
  cnt++;
}
int main() {
  scanf("%d", &n);
  dep[1] = 1;
  for (int i = (2); i <= (n); ++i) {
    int x;
    scanf("%d", &x);
    fa[i] = ++x;
    dep[i] = dep[x] + 1;
    g[x].push_back(i);
  }
  int mx = max_element(dep + 1, dep + 1 + n) - dep;
  while (mx != 1) son[fa[mx]] = mx, mx = fa[mx];
  dfs(1);
  for (auto x : id) printf("%d ", x - 1);
  puts("");
  printf("%d\n", (int)mov.size());
  for (auto x : mov) printf("%d ", x - 1);
  puts("");
}
