#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const long long LLINF = 1000000000000000007LL;
const double EPS = 1e-9;
const int sz = 200100;
int p[sz], pc[sz];
vector<int> b;
vector<pair<int, int> > g[sz];
int dfs_cnt(int v) {
  int mx = 0;
  for (int i = 0; i < g[v].size(); ++i) {
    g[v][i].first = dfs_cnt(g[v][i].second);
    mx = max(mx, g[v][i].first + 1);
  }
  sort(g[v].begin(), g[v].end());
  return mx;
}
void dfs(int v) {
  if (v) pc[v] = b.back();
  b.push_back(v);
  for (int i = 0; i < g[v].size(); ++i) {
    dfs(g[v][i].second);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> p[i];
    g[p[i]].push_back({0, i});
  }
  dfs_cnt(0);
  dfs(0);
  vector<int> ans;
  for (int i = 2; i < n; ++i) {
    while (pc[b[i]] != p[b[i]]) {
      ans.push_back(b[i]);
      pc[b[i]] = pc[pc[b[i]]];
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << b[i] << ' ';
  }
  cout << endl << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << ' ';
  }
}
