#include <bits/stdc++.h>
using namespace std;
int n, ind[100005], d[100005];
vector<int> g[100005];
vector<int> ans;
void dfs1(int v) {
  if (g[v].empty()) return;
  d[v] = 0;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    dfs1(to);
    d[v] = max(d[v], d[to] + 1);
  }
}
void dfs(int v, int dist) {
  ind[dist] = v;
  if (g[v].empty()) return;
  sort(g[v].begin(), g[v].end(), [](int a, int b) { return d[a] < d[b]; });
  while (g[v].size() > 1) {
    if (d[g[v][g[v].size() - 2]] > d[g[v][g[v].size() - 1]])
      swap(g[v][g[v].size() - 2], g[v][g[v].size() - 1]);
    int to = g[v].back();
    g[v].pop_back();
    ans.push_back(to);
    g[g[v][g[v].size() - 1]].push_back(to);
    d[g[v][g[v].size() - 1]] = max(d[to] + 1, d[g[v][g[v].size() - 1]]);
  }
  dfs(g[v].back(), dist + 1);
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    g[p].push_back(i);
  }
  dfs1(0);
  dfs(0, 0);
  for (int i = 0; i < n; i++) printf("%d ", ind[i]);
  cout << endl;
  cout << ans.size() << endl;
  while (!ans.empty()) {
    printf("%d ", ans.back());
    ans.pop_back();
  }
  cout << endl;
  return 0;
}
