#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 500031;
int n;
vector<int> g[N];
int used[N];
int subsize[N];
vector<pair<int, int> > sons[N];
int dep[N];
int max_dep[N];
void dfs(int v) {
  used[v] = 1;
  max_dep[v] = dep[v];
  subsize[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (used[to]) continue;
    dep[to] = dep[v] + 1;
    dfs(to);
    subsize[v] += subsize[to];
    max_dep[v] = max(max_dep[v], max_dep[to]);
    sons[v].push_back(make_pair(max_dep[to], to));
  }
  sort(sons[v].begin(), sons[v].end());
}
int maps[N];
vector<int> ans_moves;
void solve(int cur, int l, int r) {
  maps[l] = cur;
  int ttl_used = 1;
  for (int i = 0; i < sons[cur].size(); i++) {
    int vertex_here = sons[cur][i].second;
    int need_here = subsize[vertex_here];
    solve(vertex_here, l + ttl_used, l + ttl_used + need_here - 1);
    ttl_used += need_here;
    if (i + 1 < sons[cur].size()) {
      for (int j = 0; j < max_dep[vertex_here] - dep[cur]; j++) {
        ans_moves.push_back(l + ttl_used);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int par;
    cin >> par;
    g[par].push_back(i);
  }
  dfs(0);
  solve(0, 0, n - 1);
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << maps[i];
  }
  cout << endl;
  cout << ans_moves.size() << endl;
  for (int i = 0; i < ans_moves.size(); i++) {
    if (i) cout << " ";
    cout << maps[ans_moves[i]];
  }
  cout << endl;
  return 0;
}
