#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> adj[N];
int sz[N], deep[N], pa[N], dad[N], q[N], qf, qb;
void dfs(int u) {
  q[qb++] = u;
  sz[u] = 1;
  for (auto v : adj[u]) {
    dfs(v);
    sz[u] += sz[v];
    deep[u] = max(deep[u], deep[v] + 1);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    scanf("%d", pa + i);
    adj[pa[i]].push_back(i);
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    sort(adj[i].begin(), adj[i].end(),
         [&](int i, int j) { return deep[i] < deep[j]; });
  }
  qb = 0;
  dfs(0);
  for (int i = 1; i < qb; i++) dad[q[i]] = q[i - 1];
  vector<int> res;
  for (int i = 1; i < qb; i++) {
    for (int u = q[i]; dad[u] != pa[u];) {
      res.push_back(u);
      dad[u] = dad[dad[u]];
    }
  }
  for (int i = 0; i < qb; i++) printf("%d ", q[i]);
  puts("");
  cout << res.size() << endl;
  for (auto r : res) printf("%d ", r);
  puts("");
  return 0;
}
