#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int op[N], cnt;
int op2[N], tot;
vector<int> v[N];
int mx[N];
int cmp(int x, int y) { return mx[x] > mx[y]; }
void dfsmx(int u) {
  mx[u] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    dfsmx(v[u][i]);
    mx[u] = max(mx[u], mx[v[u][i]] + 1);
  }
}
void dfsans(int u) {
  if (mx[u] == 1)
    return;
  else {
    sort(v[u].begin(), v[u].end(), cmp);
    dfsans(v[u][0]);
    for (int i = 1; i < v[u].size(); i++) {
      for (int j = 1; j <= mx[v[u][i]]; j++) {
        op[++cnt] = v[u][i - 1];
      }
      dfsans(v[u][i]);
    }
  }
}
void dfslk(int u) {
  op2[++tot] = u;
  for (int i = v[u].size() - 1; i >= 0; i--) dfslk(v[u][i]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int f;
    scanf("%d", &f);
    v[f].push_back(i);
  }
  dfsmx(0);
  dfsans(0);
  dfslk(0);
  for (int i = 1; i <= tot; i++) printf("%d ", op2[i]);
  printf("\n");
  printf("%d\n", cnt);
  for (int i = cnt; i >= 1; i--) printf("%d ", op[i]);
}
