#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, Ans, f[N], fa[N], dep[N], dfn[N], Son[N];
vector<int> G[N];
void dfs(int u) {
  dfn[++m] = u;
  for (auto v : G[u])
    if (v != Son[u]) dfs(v);
  if (Son[u]) dfs(Son[u]);
}
int main() {
  scanf("%d", &n);
  for (int i = 2, u; i <= n; ++i) {
    scanf("%d", &u);
    fa[i] = ++u;
    G[u].push_back(i);
    dep[i] = dep[u] + 1;
  }
  for (int i = n; i > 1; --i) {
    if (f[i] + 1 > f[fa[i]]) {
      f[fa[i]] = f[i] + 1;
      Son[fa[i]] = i;
    }
  }
  dfs(1);
  for (int i = 1; i <= n; ++i) {
    printf("%d%c", dfn[i] - 1, " \n"[i == n]);
  }
  for (int i = 2; i <= n; ++i) {
    Ans += dep[dfn[i - 1]] - dep[fa[dfn[i]]];
  }
  printf("%d\n", Ans);
  for (int i = 2; i <= n; ++i) {
    for (int j = dep[dfn[i - 1]] - dep[fa[dfn[i]]]; j; --j) {
      printf("%d ", dfn[i] - 1);
    }
  }
  return 0;
}
