#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
const int N = 1e5;
int n;
int fa[N + 1];
struct Edge {
  int to, next;
} edge[(N << 1) + 1];
int start[N + 1], tot;
int dep[N + 1], which[N + 1];
int sons[N + 1], tag[N + 1];
vector<int> opt, ans;
inline void addedge(int u, int v) {
  edge[++tot] = Edge{v, start[u]};
  start[u] = tot;
  sons[u]++;
  return;
}
inline void dfs1(int u) {
  for (int i = start[u]; i; i = edge[i].next) {
    int v = edge[i].to;
    dfs1(v);
    dep[u] = max(dep[u], dep[v] + 1);
  }
  return;
}
inline void dfs2(int u) {
  bool flag = true;
  tag[u] = 1;
  for (int i = start[u]; i; i = edge[i].next) {
    int v = edge[i].to;
    if (dep[u] == dep[v] + 1 && flag) {
      which[u] = v;
      dfs2(v);
      flag = false;
    }
  }
  if (sons[u] > 1) opt.push_back(u);
  return;
}
inline void dfs3(int u) {
  printf("%d ", u);
  for (int i = start[u]; i; i = edge[i].next) {
    int v = edge[i].to;
    if (fa[v] == u) dfs3(v);
  }
  return;
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    fa[i] = read();
    addedge(fa[i], i);
  }
  dfs1(0);
  dfs2(0);
  for (int i = 0; i < opt.size(); i++) {
    int u = opt[i];
    for (int j = start[u]; j; j = edge[j].next) {
      int v = edge[j].to;
      if (tag[v]) continue;
      if (fa[v] != u) continue;
      fa[which[u]] = v;
      addedge(v, which[u]);
      ans.push_back(which[u]);
      which[v] = which[u];
      which[u] = v;
      tag[v] = 1;
      if (sons[v] > 1) opt.push_back(v);
    }
  }
  dfs3(0);
  printf("\n");
  printf("%d\n", ans.size());
  for (int i = ans.size() - 1; i >= 0; i--) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
