#include <bits/stdc++.h>
using namespace std;
int par[100000];
set<int> nei[100000];
int leaf = -1, maxdepth = -1;
void DFS(int v = 0, int par = -1, int curdepth = 0) {
  if (curdepth > maxdepth) {
    maxdepth = curdepth;
    leaf = v;
  }
  for (int to : nei[v])
    if (to != par) DFS(to, v, curdepth + 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  par[0] = -1;
  for (int v = 1; v < n; ++v) {
    cin >> par[v];
    nei[par[v]].insert(v);
  }
  DFS();
  vector<int> ans;
  while (par[leaf] != -1) {
    if (nei[par[leaf]].size() == 1) {
      leaf = par[leaf];
      continue;
    }
    nei[par[leaf]].erase(leaf);
    int v = *nei[par[leaf]].begin();
    ans.push_back(leaf);
    par[leaf] = v;
    nei[v].insert(leaf);
  }
  while (true) {
    cout << leaf << ' ';
    if (!nei[leaf].empty())
      leaf = *nei[leaf].begin();
    else
      break;
  }
  cout << '\n';
  reverse(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (int v : ans) cout << v << ' ';
}
