#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 222;
vector<int> G[maxn];
int dep[maxn];
bool cmp(int a, int b) { return dep[a] < dep[b]; }
void dfs(int s, int fa) {
  for (int d : G[s]) {
    dfs(d, s);
    dep[s] = max(dep[s], dep[d] + 1);
  }
  sort(G[s].begin(), G[s].end(), cmp);
}
vector<int> ans1;
vector<int> ans;
int nowcnt;
void dfs1(int s, int fa) {
  ans1.push_back(s);
  for (int i = 1; i <= nowcnt; i++) ans.push_back(s);
  nowcnt = 0;
  for (int d : G[s]) {
    dfs1(d, s);
  }
  nowcnt++;
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int fid;
    scanf("%d", &fid);
    G[fid].push_back(i);
  }
  dfs(0, 0);
  dfs1(0, 0);
  for (int a : ans1) {
    printf("%d ", a);
  }
  cout << endl;
  cout << ans.size() << endl;
  for (int a : ans) {
    printf("%d ", a);
  }
  cout << endl;
}
signed main() { solve(); }
