#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
const int MAXN = 100011;
int N;
vector<int> G[MAXN];
int nxt[MAXN];
int dp[MAXN];
int name[MAXN];
void MAIN() {
  scanf("%d", &N);
  for (int i = 0, i_len = (N - 1); i < i_len; ++i) {
    int x;
    scanf("%d", &x);
    G[x].push_back(i + 1);
  }
  memset(nxt, -1, sizeof nxt);
  vector<int> ans;
  for (int v = N; v--;) {
    if (G[v].empty()) {
      dp[v] = 1;
      name[v] = v;
    } else {
      vector<pair<int, int> > X;
      for (__typeof((G[v]).begin()) e = (G[v]).begin(), e_end = (G[v]).end();
           e != e_end; ++e) {
        X.emplace_back(dp[*e], *e);
      }
      sort(X.begin(), X.end());
      int prv = v;
      for (int i = 0, i_len = (X.size()); i < i_len; ++i) {
        if (i) {
          for (int t = 0, t_len = (dp[X[i - 1].second]); t < t_len; ++t) {
            ans.push_back(X[i].second);
          }
        }
        nxt[prv] = X[i].second;
        prv = name[X[i].second];
      }
      dp[v] = X.back().first + 1;
      name[v] = name[X.back().second];
    }
  }
  int cur = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    printf("%d%c", cur, " \n"[i == N - 1]);
    cur = nxt[cur];
  }
  assert(cur == -1);
  printf("%d\n", (int)ans.size());
  rprintf("%d", ans.begin(), ans.end());
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
