#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int SUM = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    SUM = (SUM << 3) + (SUM << 1) + (ch ^ 48);
    ch = getchar();
  }
  return SUM * ff;
}
const int N = 100010;
struct edge {
  int nxt, to;
} e[N << 2];
int h[N], cnte = 1;
inline void addedge(int u, int v) { e[++cnte] = (edge){h[u], v}, h[u] = cnte; }
int n;
vector<int> order, up;
int fa[N], maxdep[N];
inline void dfs(int u) {
  maxdep[u] = 0;
  for (int i = h[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (fa[u] == v) continue;
    dfs(v);
    maxdep[u] = max(maxdep[u], maxdep[v]);
  }
  maxdep[u]++;
}
inline void check(int u) {
  multiset<pair<int, int> > s;
  for (int i = h[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (fa[u] == v) continue;
    s.insert(make_pair(maxdep[v], v));
  }
  if (s.empty()) return;
  for (multiset<pair<int, int> >::iterator it = s.begin(); it != s.end();
       it++) {
    order.push_back(it->second);
    check(it->second);
  }
  int pre = s.begin()->first;
  for (multiset<pair<int, int> >::iterator it = s.begin(); it != s.end();
       it++) {
    if (it != s.begin()) {
      for (int i = 1; i <= pre; i++) {
        up.push_back(it->second);
      }
      pre = it->first;
    }
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n - 1; i++) {
    fa[i] = read();
    addedge(i, fa[i]), addedge(fa[i], i);
  }
  order.push_back(0);
  dfs(0);
  check(0);
  for (int i = 0; i < order.size(); i++) printf("%d ", order[i]);
  puts("");
  printf("%d\n", up.size());
  for (int i = 0; i < up.size(); i++) printf("%d ", up[i]);
  return 0;
}
