#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> g[N], v;
int ord[N], mx[N];
int lo = 0, z = 0;
int n;
void dive(int node) {
  for (int to : g[node]) {
    dive(to);
    mx[node] = max(mx[node], mx[to] + 1);
  }
  sort(g[node].begin(), g[node].end(),
       [](int x, int y) { return mx[x] < mx[y]; });
}
void dfs(int node) {
  ord[lo++] = node;
  for (int to : g[node]) {
    dfs(to);
  }
}
void deep(int node) {
  z++;
  for (int to : g[node]) {
    deep(to);
    if (z < n) v.push_back(ord[z]);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x;
    cin >> x;
    g[x].push_back(i);
  }
  dive(0);
  dfs(0);
  deep(0);
  for (int i = 0; i < n; i++) {
    cout << ord[i] << " ";
  }
  cout << "\n" << v.size() << "\n";
  for (int x : v) {
    cout << x << "\n";
  }
  return 0;
}
