#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int n, par[N], up[N], h[N], max_h[N];
vector<int> child[N], vec, ans;
void dfs(int v = 0) {
  for (int u : child[v]) {
    h[u] = max_h[u] = h[v] + 1;
    dfs(u);
    max_h[v] = max(max_h[v], max_h[u]);
  }
  sort(child[v].begin(), child[v].end(),
       [](int u, int v) { return max_h[u] < max_h[v]; });
}
void bamboo(int v = 0) {
  if (v) up[v] = vec.back();
  vec.push_back(v);
  for (int u : child[v]) bamboo(u);
}
void solve(int v = 0) {
  while (v && up[v] != par[v]) {
    ans.push_back(v);
    up[v] = up[up[v]];
  }
  for (int u : child[v]) solve(u);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> par[i];
    child[par[i]].push_back(i);
  }
  dfs();
  bamboo();
  for (int v : vec) cout << v << ' ';
  cout << '\n';
  solve();
  cout << ans.size() << '\n';
  for (int u : ans) cout << u << ' ';
}
