#include <bits/stdc++.h>
using namespace std;
int n;
int p[100005];
vector<int> ch[100005];
int d[100005];
int md[100005];
void gd(int cn) {
  md[cn] = d[cn];
  for (auto &nn : ch[cn]) {
    d[nn] = d[cn] + 1;
    gd(nn);
    md[cn] = max(md[cn], md[nn]);
    if (md[nn] > md[ch[cn][0]]) {
      swap(nn, ch[cn][0]);
    }
  }
}
vector<int> od;
vector<int> op;
void res(int cn) {
  od.push_back(cn);
  for (auto u : ch[cn]) {
    md[u] = md[cn];
  }
  for (int i = (1); i <= (signed)(ch[cn].size() - 1); i++) {
    int fn = ch[cn][i - 1], nn = ch[cn][i];
    op.push_back(fn);
    ++md[fn];
    md[nn] = md[fn];
    ch[nn].push_back(fn);
    if (md[fn] > md[ch[nn][0]]) {
      swap(ch[nn][0], ch[nn][ch[nn].size() - 1]);
    }
  }
  if (ch[cn].size() != 0) {
    res(ch[cn][ch[cn].size() - 1]);
  }
}
int main() {
  cin >> n;
  for (int i = (1); i <= (signed)(n - 1); i++) {
    cin >> p[i];
    ch[p[i]].push_back(i);
  }
  gd(0);
  res(0);
  for (auto u : od) {
    cout << u << " ";
  }
  cout << "\n";
  cout << op.size() << "\n";
  for (int i = (op.size() - 1); i >= 0; i--) {
    cout << op[i] << " ";
  }
  cout << "\n";
  return 0;
}
