#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int f = 1, x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
struct edge {
  int v, next;
} e[200001];
int cnt, head[100001], fa[100001], maxn[100001];
vector<int> ord, up;
inline void add(int u, int v) {
  e[++cnt] = (edge){v, head[u]};
  head[u] = cnt;
}
inline void dfs(int u) {
  maxn[u] = 0;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].v;
    if (fa[u] != v) {
      dfs(v);
      maxn[u] = max(maxn[u], maxn[v]);
    }
  }
  maxn[u] += 1;
}
inline void check(int u) {
  multiset<pair<int, int> > s;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].v;
    if (fa[u] != v) s.insert(make_pair(maxn[v], v));
  }
  if (s.empty()) return;
  for (multiset<pair<int, int> >::iterator it = s.begin(); it != s.end();
       ++it) {
    ord.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() {
  memset(head, -1, sizeof head);
  int n = read();
  for (int i = 1; i < n; ++i) {
    int u = read();
    fa[i] = u;
    add(u, i);
    add(i, u);
  }
  ord.push_back(0);
  dfs(0);
  check(0);
  for (int i = 0; i < ord.size(); ++i) printf("%d ", ord[i]);
  printf("\n%d\n", up.size());
  for (int i = 0; i < up.size(); ++i) printf("%d ", up[i]);
  return 0;
}
