#include <bits/stdc++.h>
using namespace std;
void _in(long long *a, ...) {
  va_list arg_ptr;
  scanf("%I64d", a);
  long long *temp;
  va_start(arg_ptr, a);
  temp = va_arg(arg_ptr, long long *);
  while (temp) {
    scanf("%I64d", temp);
    temp = va_arg(arg_ptr, long long *);
  }
  va_end(arg_ptr);
}
void _in(int *a, ...) {
  va_list arg_ptr;
  scanf("%d", a);
  int *temp;
  va_start(arg_ptr, a);
  temp = va_arg(arg_ptr, int *);
  while (temp) {
    scanf("%d", temp);
    temp = va_arg(arg_ptr, int *);
  }
  va_end(arg_ptr);
}
const int N = 1e5 + 100;
vector<int> G[N];
stack<int> ans;
int fa[N], n, num[N], maxl, maxd, son[N], sonp[N];
void dfs(int o, int dep) {
  if (dep > maxd) {
    maxd = dep;
    maxl = o;
  }
  for (int it : G[o]) {
    dfs(it, dep + 1);
  }
}
int main() {
  _in(&n, 0);
  for (int i = 1; i <= n - 1; i++) {
    int t;
    _in(&t, 0);
    G[t].push_back(i);
    num[t]++;
    fa[i] = t;
    sonp[i] = G[t].size() - 1;
  }
  dfs(0, 1);
  int o = maxl;
  while (o) {
    son[fa[o]] = o;
    o = fa[o];
  }
  o = maxl;
  while (o) {
    if (num[fa[o]] <= 1) {
      o = fa[o];
      continue;
    }
    int mes;
    for (int it : G[fa[o]]) {
      if (it != o && it != -1) {
        mes = it;
        break;
      }
    }
    if (G[fa[o]].size() > sonp[o] && G[fa[o]][sonp[o]] == o)
      G[fa[o]][sonp[o]] = -1;
    num[mes]++;
    num[fa[o]]--;
    son[fa[o]] = mes;
    fa[o] = mes;
    son[mes] = o;
    ans.push(o);
  }
  o = 0;
  printf("%d ", o);
  while (son[o]) {
    o = son[o];
    printf("%d ", o);
  }
  printf("\n%d\n", ans.size());
  while (!ans.empty()) {
    int t = ans.top();
    ans.pop();
    printf("%d ", t);
  }
  return 0;
}
