#include <bits/stdc++.h>
using namespace std;
vector<int> sub, ord, ans;
vector<vector<int>> g;
void dfs(int x) {
  sub[x] = 1;
  for (auto v : g[x]) {
    dfs(v);
    sub[x] = max(sub[x], sub[v] + 1);
  }
}
void getans(int x) {
  ord.push_back(x);
  for (int i = 0; i < (int)g[x].size(); ++i) {
    getans(g[x][i]);
    if (i) {
      for (int j = 0; j < sub[g[x][i - 1]]; ++j) {
        ans.push_back(g[x][i]);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  g.resize(n);
  sub.resize(n, 0);
  for (int i = 1; i < n; ++i) {
    int p;
    cin >> p;
    g[p].push_back(i);
  }
  dfs(0);
  for (int i = 0; i < n; ++i) {
    sort(g[i].begin(), g[i].end(),
         [&](int l, int r) { return sub[l] < sub[r]; });
  }
  getans(0);
  for (auto i : ord) cout << i << " ";
  cout << '\n';
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i << " ";
  cout << '\n';
}
