#include <bits/stdc++.h>
using namespace std;
const int N = 12e4;
vector<int> ch[N], v;
int f[N], c[N], d[N], u[N];
void dfs_s(int x) {
  for (int y : ch[x]) {
    c[y] = c[x] + 1;
    dfs_s(y);
  }
}
bool cmp(int a, int b) { return u[a] < u[b]; }
int dfs_a(int x) {
  int t = x;
  sort(ch[x].begin(), ch[x].end(), cmp);
  for (int y : ch[x]) {
    d[t] = y;
    for (int i = 0; i < c[t] - c[x]; i++) v.push_back(y);
    t = dfs_a(y);
  }
  return t;
}
int main() {
  int n, m = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> f[i];
    ch[f[i]].push_back(i);
  }
  dfs_s(0);
  for (int i = 1; i < n; i++)
    if (c[m] < c[i]) m = i;
  while (m) {
    u[m] = 1;
    m = f[m];
  }
  memset(d, -1, sizeof d);
  dfs_a(0);
  for (int i = 0; i >= 0; i = d[i]) cout << i << ' ';
  cout << '\n' << v.size() << '\n';
  for (int i : v) cout << i << ' ';
  return 0;
}
