#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, dep[N], p[N], p_building[N];
vector<int> g[N], bamboo, ans;
void dfs(int u) {
  for (int v : g[u]) {
    dfs(v);
    dep[u] = max(dep[u], dep[v]);
  }
  ++dep[u];
  sort(g[u].begin(), g[u].end(), [&](int x, int y) { return dep[x] < dep[y]; });
}
void make_bamboo(int u) {
  if (u) {
    p_building[u] = bamboo.back();
    while (p_building[u] != p[u]) {
      ans.push_back(u);
      p_building[u] = p_building[p_building[u]];
    }
  }
  bamboo.push_back(u);
  for (int v : g[u]) make_bamboo(v);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> p[i];
    g[p[i]].push_back(i);
  }
  dfs(0);
  make_bamboo(0);
  for (int u : bamboo) cout << u << " ";
  cout << "\n" << (int)ans.size() << "\n";
  for (int u : ans) cout << u << " ";
  return 0;
}
