#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int p[N], deg[N], n, cur;
vector<int> g[N], ans;
bool cmp(int x, int y) { return deg[x] < deg[y]; }
void dfs1(int u, int d) {
  deg[u] = d;
  for (auto v : g[u]) {
    dfs1(v, d + 1);
    deg[u] = max(deg[u], deg[v]);
  }
  sort(g[u].begin(), g[u].end(), cmp);
}
void dfs2(int u) {
  p[cur] = u;
  cur++;
  for (auto v : g[u]) dfs2(v);
  if (cur < n) ans.push_back(cur);
}
int main() {
  scanf("%d", &n);
  cur = 0;
  for (int i = 1, j; i < n; ++i) {
    scanf("%d", &j);
    g[j].push_back(i);
  }
  dfs1(0, 0);
  dfs2(0);
  for (int i = 0; i < n; ++i) printf("%d ", p[i]);
  printf("\n%d\n", ans.size());
  for (auto q : ans) printf("%d ", p[q]);
  printf("\n");
}
