#include <bits/stdc++.h>
using namespace std;
int n, depth[100005];
vector<int> g[100005];
void preDFS(int u, int pa) {
  depth[u] = 1;
  for (auto &v : g[u]) {
    if (v == pa) {
      swap(v, g[u].back());
      g[u].pop_back();
    }
    preDFS(v, u);
    depth[u] = max(depth[u], depth[v] + 1);
  }
}
bool cmp(int u, int v) { return depth[u] < depth[v]; }
int tt = 0, id[100005];
vector<int> res;
void DFS(int u, int pa) {
  sort(g[u].begin(), g[u].end(), cmp);
  id[++tt] = u;
  int pre = 0;
  for (auto v : g[u]) {
    DFS(v, u);
    for (int i = 1; i <= pre; i++) res.push_back(v);
    pre = depth[v];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("INP.TXT", "r")) {
    freopen("INP.TXT", "r", stdin);
  }
  cin >> n;
  for (int v = 2; v <= n; v++) {
    int u;
    cin >> u;
    u++;
    g[u].push_back(v);
  }
  preDFS(1, -1);
  DFS(1, -1);
  for (int i = 1; i <= n; i++) cout << id[i] - 1 << ' ';
  cout << '\n' << res.size() << '\n';
  for (auto u : res) cout << u - 1 << ' ';
}
