#include <bits/stdc++.h>
using namespace std;
int n;
int disFromLeaf[100000], par[100000], rev[100000];
bool solved[100000];
vector<int> children[100000];
vector<int> steps;
void dfs(int node) {
  for (const int next : children[node]) {
    dfs(next);
    disFromLeaf[node] = max(disFromLeaf[next] + 1, disFromLeaf[node]);
  }
}
void solve(int node) {
  if (((int)((children[node]).size())) == 0 || solved[node]) {
    return;
  }
  vector<pair<int, int> > v;
  for (const int next : children[node]) {
    v.emplace_back(disFromLeaf[next], next);
  }
  sort(v.begin(), v.end());
  for (int i = ((int)((v).size())) - 1; i >= 0; i--) {
    solve(v[i].second);
    disFromLeaf[node] = max(disFromLeaf[node], disFromLeaf[v[i].second] + 1);
    if (i > 0) {
      par[v[i].second] = v[i - 1].second;
      children[v[i - 1].second].push_back(v[i].second);
      disFromLeaf[v[i - 1].second] =
          max(disFromLeaf[v[i - 1].second], disFromLeaf[v[i].second] + 1);
      steps.push_back(v[i].second);
    }
  }
  solved[node] = 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> par[i];
    children[par[i]].push_back(i);
  }
  dfs(0);
  solve(0);
  for (int i = 1; i < n; i++) {
    rev[par[i]] = i;
  }
  int curr = 0;
  cout << 0;
  for (int i = 1; i < n; i++) {
    cout << " " << rev[curr];
    curr = rev[curr];
  }
  cout << "\n";
  cout << ((int)((steps).size())) << "\n";
  for (int i = ((int)((steps).size())) - 1; i >= 0; i--) {
    cout << steps[i] << " ";
  }
  cout << "\n";
  return 0;
}
