#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
unordered_set<long long> g[N];
long long parent[N], depth[N];
int main() {
  long long n;
  cin >> n;
  depth[0] = 1;
  long long max_depth = 0, node;
  for (long long i = 1; i < n; i++) {
    cin >> parent[i];
    g[parent[i]].insert(i);
    depth[i] = depth[parent[i]] + 1;
    if (depth[i] > max_depth) {
      max_depth = depth[i];
      node = i;
    }
  }
  vector<long long> ans;
  while (node != 0) {
    if (g[parent[node]].size() > 1) {
      ans.push_back(node);
      long long next_node;
      if (*(g[parent[node]].begin()) != node) {
        next_node = *(g[parent[node]].begin());
      } else {
        unordered_set<long long>::iterator itr;
        long long cnt = 0;
        for (itr = g[parent[node]].begin(); itr != g[parent[node]].end();
             itr++) {
          cnt++;
          if (cnt == 2) break;
        }
        next_node = *itr;
      }
      g[parent[node]].erase(node);
      g[next_node].insert(node);
      parent[node] = next_node;
    } else {
      node = parent[node];
    }
  }
  while (true) {
    cout << node << " ";
    if (g[node].size() == 0) break;
    node = *(g[node].begin());
  }
  cout << endl;
  reverse(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
