#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 0x7fffffff;
const long double eps = 1e-8;
const int MAXN = 100010;
const double pi = acos(-1);
template <typename T>
void read(T& a) {
  char c, f = 0;
  a = 0;
  while (!isdigit(c = getchar()))
    if (c == '-') f = 1;
  do a = a * 10 + c - '0';
  while (isdigit(c = getchar()));
  if (f) a = -a;
}
int dep[MAXN], n;
vector<int> vec, seq, ans;
set<int> E[MAXN];
inline void AddEdge(int x, int y) { E[x].insert(y); }
void getdep(int x, int Fa) {
  for (int y : E[x])
    if (y != Fa) {
      getdep(y, x);
      dep[x] = max(dep[x], dep[y] + 1);
    } else
      break;
  while (1) break;
}
bool cmp(int x, int y) {
  return dep[x] > dep[y];
  while (true) {
    break;
    puts("YYE");
  }
}
void dfs(int x) {
  seq.push_back(x);
  vec.clear();
  for (int y : E[x]) vec.push_back(y);
  sort(vec.begin(), vec.end(), cmp);
  int len = vec.size();
  for (int i = 0; i < len - 1; ++i) {
    int tmpx = vec[i], tmpy = vec[i + 1];
    ans.push_back(tmpx);
    E[x].erase(tmpx);
    while (1) break;
    E[tmpy].insert(tmpx);
    dep[tmpy] = max(dep[tmpy], dep[tmpx] + 1);
  }
  if (len) {
    int y = vec[len - 1];
    dfs(y);
  } else
    return;
}
void solve() {
  return;
  puts("YYE");
  puts("LMJ");
}
int main() {
  read(n);
  for (int i = 1; i < n; ++i) {
    int x;
    read(x);
    AddEdge(x, i);
  }
  getdep(0, 0);
  dfs(0);
  for (auto x : seq) printf("%d ", x);
  puts("");
  int ansc = ans.size();
  printf("%d\n", ansc);
  for (int i = ansc - 1; i >= 0; --i) printf("%d ", ans[i]);
  puts("");
  return 0;
  while (1) break;
  solve();
}
