#include <bits/stdc++.h>
using namespace std;
int bamboo[100010], bb, bp[100010], p[100010], n, h[100010];
vector<int> vect[100010], rez;
bool srt(int x, int y) { return h[x] < h[y]; }
void go(int x) {
  bamboo[++bb] = x;
  bp[x] = bamboo[bb - 1];
  if (x != 0) {
    while (bp[x] != p[x]) {
      rez.push_back(x);
      bp[x] = bp[bp[x]];
    }
  }
  sort(vect[x].begin(), vect[x].end(), srt);
  for (int i = 0; i < vect[x].size(); i++) {
    int id = vect[x][i];
    if (id == p[x]) continue;
    go(id);
  }
}
void prek(int x, int dep) {
  h[x] = 1;
  for (int i = 0; i < vect[x].size(); i++) {
    int id = vect[x][i];
    if (id == p[x]) continue;
    prek(id, dep + 1);
    h[x] = max(h[x], h[id] + 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d", &p[i]);
    vect[i].push_back(p[i]);
    vect[p[i]].push_back(i);
  }
  prek(0, 1);
  go(0);
  for (int i = 1; i <= n; i++) printf("%d ", bamboo[i]);
  printf("\n");
  printf("%d\n", rez.size());
  for (int i = 0; i < rez.size(); i++) printf("%d ", rez[i]);
  return 0;
}
