#include <bits/stdc++.h>
using namespace std;
const int MX = 100005;
int p[MX];
vector<int> neigh[MX];
int h[MX];
int main() {
  int n;
  ignore = scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    ignore = scanf("%d", p + i);
    neigh[p[i]].push_back(i);
  }
  for (int i = n - 1; i > 0; i--) {
    h[p[i]] = max(h[p[i]], h[i] + 1);
  }
  vector<int> Q;
  vector<int> order;
  order.push_back(0);
  for (int rep = 1; rep < n; rep++) {
    int par = order.back();
    set<pair<int, int>> S;
    for (auto v : neigh[par]) {
      S.insert({h[v], v});
    }
    while (S.size() > 1) {
      auto lo = S.begin();
      auto hi = prev(S.end());
      int id = lo->second;
      int new_h = hi->first + 1;
      Q.push_back(hi->second);
      neigh[id].push_back(hi->second);
      S.erase(lo);
      S.erase(hi);
      h[id] = new_h;
      S.insert({h[id], id});
    }
    order.push_back(S.begin()->second);
  }
  for (int x : order) printf("%d ", x);
  printf("\n");
  printf("%d\n", (int)Q.size());
  reverse(Q.begin(), Q.end());
  for (int x : Q) printf("%d ", x);
}
