#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct Edge {
  int nxt, to;
} e[maxn << 1];
int hd[maxn], e_cnt;
void add(int u, int v) {
  e[++e_cnt] = (Edge){hd[u], v};
  hd[u] = e_cnt;
}
int n, dep[maxn], p[maxn], maxi, son[maxn];
vector<int> seq, op;
void dfs(int u, int r, int carry) {
  if (carry != -1) op.push_back(carry);
  if (son[u]) dfs(son[u], u, -1), carry = son[u];
  for (int i = hd[u]; i; i = e[i].nxt)
    if (e[i].to != son[u]) dfs(e[i].to, u, carry), carry = e[i].to;
  seq.push_back(u);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    cin >> p[i];
    add(p[i], i);
    dep[i] = dep[p[i]] + 1;
    maxi = max(maxi, dep[i]);
  }
  for (int i = 1; i <= n - 1; i++)
    if (maxi == dep[i]) {
      int u = i;
      while (true) {
        son[p[u]] = u;
        u = p[u];
        if (!u) break;
      }
      break;
    }
  dfs(0, 0, -1);
  for (int i = n - 1; i >= 0; i--) cout << seq[i] << ' ';
  cout << '\n';
  cout << op.size() << '\n';
  for (int i = (int)(op.size()) - 1; i >= 0; i--) cout << op[i] << ' ';
  return 0;
}
