#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, fa, h[N];
vector<int> G[N], p, q;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n - 1); ++i) scanf("%d", &fa), G[fa].push_back(i);
  function<void(int)> dfs = [&](int u) {
    for (int v : G[u]) dfs(v), h[u] = max(h[u], h[v] + 1);
  };
  dfs(0);
  function<int(int, int)> solve = [&](int u, int nd) {
    sort(G[u].begin(), G[u].end(), [&](int x, int y) { return h[x] < h[y]; });
    p.push_back(u);
    for (int i = (1); i <= (nd); ++i) q.push_back(u);
    nd = 0;
    for (int v : G[u]) nd = solve(v, nd);
    return nd + 1;
  };
  solve(0, 0);
  for (int x : p) printf("%d ", x);
  printf("\n%d\n", q.size());
  for (int x : q) printf("%d ", x);
  return 0;
}
