#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj;
vector<int> depth, max_depth, bambooed;
void dfs_depth(int current_v) {
  max_depth[current_v] = depth[current_v];
  for (auto next_v : adj[current_v]) {
    depth[next_v] = depth[current_v] + 1;
    dfs_depth(next_v);
    max_depth[current_v] = max(max_depth[next_v], max_depth[current_v]);
  }
}
void mark_special_path(int current_v) {
  while (!adj[current_v].empty()) {
    int spl_idx = -1;
    for (int i = 0; i < adj[current_v].size(); ++i) {
      if (max_depth[current_v] == max_depth[adj[current_v][i]]) {
        spl_idx = i;
        break;
      }
    }
    for (int i = spl_idx; i < adj[current_v].size() - 1; ++i) {
      swap(adj[current_v][i], adj[current_v][i + 1]);
    }
    current_v = adj[current_v].back();
  }
}
vector<int> operations;
void transform_tree(int current_v) {
  if (bambooed[current_v]) return;
  while (adj[current_v].size() > 0) {
    int top_v = adj[current_v].back();
    transform_tree(top_v);
    if (adj[current_v].size() == 1) break;
    adj[current_v].pop_back();
    int next_v = adj[current_v].back();
    adj[next_v].push_back(top_v);
    operations.push_back(top_v);
  }
  bambooed[current_v] = 1;
}
int main() {
  int n;
  cin >> n;
  adj = vector<vector<int> >(n, vector<int>());
  depth = vector<int>(n, 0);
  max_depth = vector<int>(n, 0);
  bambooed = vector<int>(n, 0);
  vector<int> parent(n);
  for (int i = 1; i < n; ++i) {
    int parent_i;
    cin >> parent_i;
    adj[parent_i].push_back(i);
  }
  dfs_depth(0);
  mark_special_path(0);
  transform_tree(0);
  int current_v = 0;
  for (int i = 0; i < n; ++i) {
    cout << current_v << " ";
    if (i < n - 1) {
      assert(adj[current_v].size() == 1);
      current_v = adj[current_v][0];
    } else {
      assert(adj[current_v].empty());
    }
  }
  cout << endl;
  cout << operations.size() << endl;
  while (!operations.empty()) {
    cout << operations.back() << " ";
    operations.pop_back();
  }
  cout << endl;
  return 0;
}
