#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
vector<long long> childs[N];
long long depth[N];
long long par[N];
bool path[N];
long long order[N];
long long t = 0;
vector<long long> moves;
vector<long long> extraNodes[N];
void dfs(long long node) {
  order[t++] = node;
  if (childs[node].empty()) return;
  if (!extraNodes[node].empty()) {
    assert(extraNodes[node].size() == 1);
    moves.push_back(extraNodes[node][0]);
  }
  for (long long i = (long long)childs[node].size() - 1; i >= 1; --i) {
    moves.push_back(childs[node][i]);
  }
  for (long long i = 1; i < (long long)childs[node].size(); ++i) {
    extraNodes[childs[node][i - 1]].push_back(childs[node][i]);
  }
  if (!extraNodes[node].empty() && !childs[node].empty()) {
    assert(extraNodes[node].size() == 1);
    extraNodes[childs[node].back()].push_back(extraNodes[node][0]);
  }
  for (long long to : childs[node]) {
    dfs(to);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  depth[0] = 0;
  for (long long i = 1; i < n; ++i) {
    long long p;
    cin >> p;
    childs[p].push_back(i);
    par[i] = p;
    depth[i] = 1 + depth[p];
  }
  long long lowest = 0;
  for (long long i = 1; i < n; ++i) {
    if (depth[i] > depth[lowest]) {
      lowest = i;
    }
  }
  long long node = lowest;
  while (node > 0) {
    path[node] = true;
    node = par[node];
  }
  for (long long node = 0; node < n; ++node) {
    for (long long i = 0; i < (long long)childs[node].size(); ++i) {
      if (path[childs[node][i]]) {
        childs[node].push_back(childs[node][i]);
        childs[node].erase(childs[node].begin() + i);
        break;
      }
    }
  }
  dfs(0);
  for (long long i = 0; i < n; ++i) {
    cout << order[i] << ' ';
  }
  cout << '\n';
  assert((long long)moves.size() == n - 1 - depth[lowest]);
  cout << moves.size() << '\n';
  for (long long i = (long long)moves.size() - 1; i >= 0; --i) {
    cout << moves[i] << ' ';
  }
}
