#include <bits/stdc++.h>
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
const int MAX_N = 100010;
int n;
int par[MAX_N];
vector<int> ch[MAX_N];
int maxdepth[MAX_N];
vector<int> res;
void computeDepths(int u) {
  int res = 0;
  for (int v : ch[u]) {
    computeDepths(v);
    ckmax(res, maxdepth[v] + 1);
  }
  maxdepth[u] = res;
}
void solve(int u) {
  if ((int)ch[u].size() == 0)
    return;
  else if ((int)ch[u].size() == 1)
    solve(ch[u][0]);
  else {
    int other = ch[u][(int)ch[u].size() - 2];
    pair<int, int> bes = make_pair(maxdepth[ch[u].back()], ch[u].back());
    maxdepth[other] = bes.first + 1;
    res.push_back(bes.second);
    ch[u].pop_back();
    ch[other].push_back(bes.second);
    solve(u);
  }
}
vector<pair<int, int> > chsorted[MAX_N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> par[i];
    ch[par[i]].push_back(i);
  }
  computeDepths(0);
  for (int i = 1; i < n; i++) {
    chsorted[par[i]].push_back(make_pair(maxdepth[i], i));
  }
  for (int i = 0; i < n; i++) {
    sort(chsorted[i].begin(), chsorted[i].end());
    ch[i].clear();
    for (pair<int, int> p : chsorted[i]) ch[i].push_back(p.second);
  }
  solve(0);
  vector<int> nodes;
  int cur = 0;
  nodes.push_back(cur);
  while (1) {
    if ((int)ch[cur].size() == 1) {
      cur = *ch[cur].begin();
      nodes.push_back(cur);
    } else {
      break;
    }
  }
  for (int i = 0; i < n; i++) cout << nodes[i] << " ";
  reverse(res.begin(), res.end());
  cout << "\n";
  cout << (int)res.size() << "\n";
  for (int x : res) cout << x << " ";
  cout << "\n";
}
