#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int n;
vector<int> p[N];
int mxLev[N];
void init(int x) {
  for (int i = 0; i < p[x].size(); i++) {
    init(p[x][i]);
    mxLev[x] = max(mxLev[x], mxLev[p[x][i]]);
  }
  mxLev[x]++;
}
stack<int> res;
int child[N];
void pro(int x) {
  vector<pair<int, int> > ch;
  for (int i = 0; i < p[x].size(); i++) {
    ch.push_back({mxLev[p[x][i]], p[x][i]});
  }
  sort(ch.begin(), ch.end());
  reverse(ch.begin(), ch.end());
  for (int i = 0; i < ((int)ch.size()) - 1; i++) {
    p[ch[i + 1].second].push_back(ch[i].second);
    res.push(ch[i].second);
    mxLev[ch[i + 1].second] =
        max(mxLev[ch[i + 1].second], mxLev[ch[i].second] + 1);
  }
  if (ch.empty()) {
    child[x] = -1;
    return;
  }
  child[x] = ch.back().second;
  pro(child[x]);
}
int main() {
  cin >> n;
  int pp;
  for (int i = 1; i < n; i++) {
    scanf("%d", &pp);
    p[pp].push_back(i);
  }
  init(0);
  pro(0);
  int x = 0;
  while (x != -1) {
    printf("%d ", x);
    x = child[x];
  }
  printf("\n%d\n", res.size());
  while (!res.empty()) {
    printf("%d ", res.top());
    res.pop();
  }
  return 0;
}
