#include <bits/stdc++.h>
using namespace std;
vector<int> p;
vector<vector<int>> g;
vector<int> h;
int find_h(int v) {
  h[v] = 1;
  for (int u : g[v]) {
    h[v] = max(h[v], find_h(u) + 1);
  }
  return h[v];
}
vector<int> b;
vector<int> actions;
void dfs(int v) {
  b.push_back(v);
  vector<array<int, 2>> children;
  for (int u : g[v]) {
    children.push_back({h[u], u});
  }
  sort(children.begin(), children.end());
  for (int i = 0; i < ((int)children.size()); i++) {
    int u = children[i][1];
    dfs(u);
    if (i > 0) {
      for (int j = 0; j < h[children[i - 1][1]]; j++) {
        actions.push_back(u);
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  p.resize(n);
  p[0] = -1;
  g.resize(n);
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  h.resize(n);
  find_h(0);
  dfs(0);
  for (int i = 0; i < n; i++) {
    cout << b[i] << ' ';
  }
  cout << '\n';
  cout << ((int)actions.size()) << '\n';
  for (int a : actions) {
    cout << a << ' ';
  }
  cout << '\n';
  return 0;
}
