#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, fa[N], ans[N], len, son[N], dep[N], mx[N];
set<int> E[N];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++)
    E[fa[i] = gi()].insert(i), dep[i] = dep[fa[i]] + 1;
  for (int i = n - 1; i; i--) mx[fa[i]] = max(mx[fa[i]], mx[i] + 1);
  int Mx = -1, u = -1;
  for (int i = 0; i < n; i++) Mx = max(Mx, dep[i]);
  for (int i = 0; i < n; i++)
    if (dep[i] + mx[i] == Mx && int(E[fa[i]].size()) > 1 &&
        (u == -1 || dep[i] > dep[u]))
      u = i;
  len = n - 1 - Mx;
  for (int i = 1; i <= len; i++) {
    int p = fa[u];
    for (auto v : E[p])
      if (v != u) {
        E[p].erase(u), E[v].insert(u), fa[u] = v;
        break;
      }
    ans[i] = u;
    while (u && int(E[fa[u]].size()) == 1) u = fa[u];
  }
  u = 0;
  cout << u << ' ';
  for (int i = 1; i < n; i++) cout << *E[u].begin() << ' ', u = *E[u].begin();
  cout << '\n' << len << '\n';
  for (int i = len; i; i--) cout << ans[i] << ' ';
  return 0;
}
