#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
vector<int> E[MAXN], id, mov;
int dep[MAXN], f[MAXN], son[MAXN];
int cnt;
void dfs(int now) {
  id.push_back(now);
  for (int i = 1; i <= cnt; i++) mov.push_back(now);
  cnt = 0;
  for (int v : E[now])
    if (v != son[now]) dfs(v);
  if (son[now]) dfs(son[now]);
  cnt++;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", &f[i]);
    E[f[i]].push_back(i);
    dep[i] = dep[f[i]] + 1;
  }
  int now = max_element(dep, dep + n) - dep;
  while (now) {
    son[f[now]] = now;
    now = f[now];
  }
  dfs(0);
  for (int v : id) printf("%d ", v);
  puts("");
  printf("%d\n", (int)mov.size());
  for (int v : mov) printf("%d ", v);
  puts("");
  return 0;
}
