#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n;
vector<int> child[N];
int h[N], ptr[N], last, par[N];
bool vst[N];
int getNextChild(int u) {
  if (ptr[u] == (int)child[u].size()) return -1;
  return child[u][ptr[u]++];
}
void dfs(int u) {
  if (h[u] > h[last]) last = u;
  for (int v : child[u]) {
    h[v] = h[u] + 1;
    par[v] = u;
    dfs(v);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    child[p].push_back(i);
  }
  par[0] = -1;
  dfs(0);
  int cur = last;
  vector<int> res;
  while (cur != 0) {
    vst[cur] = 1;
    int p = par[cur];
    int v;
    while (1) {
      v = getNextChild(p);
      if (!vst[v]) break;
    }
    if (v == -1) {
      cur = p;
    } else {
      par[cur] = v;
      res.push_back(cur);
    }
  }
  vector<int> id;
  while (last != -1) {
    id.push_back(last);
    last = par[last];
  }
  reverse(id.begin(), id.end());
  reverse(res.begin(), res.end());
  for (int x : id) cout << x << ' ';
  cout << endl << res.size() << endl;
  for (int x : res) cout << x << ' ';
  return 0;
}
