#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, fa[1 << 17], a[1 << 17], _, dep[1 << 17], b[1 << 17], op[1 << 20], $;
set<int> v[1 << 17];
void pre(int p) {
  dep[p] = 0;
  for (int i : v[p]) pre(i), dep[p] = max(dep[p], dep[i] + 1);
}
void dfs(int p) {
  a[_++] = p;
  int t = 0;
  for (int i : v[p]) b[t++] = i;
  sort(b, b + t, [&](int a, int b) { return dep[a] > dep[b]; });
  for (int i = 0; i < t - 1; i++) {
    op[$++] += b[i];
    v[p].erase(b[i]);
    v[b[i + 1]].insert(b[i]);
    dep[b[i + 1]] = max(dep[b[i + 1]], dep[b[i]] + 1);
  }
  if (t) dfs(b[t - 1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d", fa + i), v[fa[i]].insert(i);
  pre(0), dfs(0);
  for (int i = 0; i < n; i++) printf("%d%c", a[i], " \n"[i == n - 1]);
  printf("%d\n", $);
  for (int i = $ - 1; ~i; i--) printf("%d%c", op[i], " \n"[!i]);
  return 0;
}
