#include <bits/stdc++.h>
using namespace std;
const int mxn = 100000;
int n, k;
int a[mxn], d[mxn];
vector<int> g[mxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1, x; i < n; i++) cin >> x, g[x].push_back(i);
  for (int i = n - 1; ~i; i--) {
    for (int j : g[i]) d[i] = max(d[i], d[j] + 1);
    sort(g[i].begin(), g[i].end(), [&](int x, int y) { return d[x] < d[y]; });
  }
  for (int i = 0; !g[i].empty(); i = g[i][0])
    while (g[i].size() > 1) {
      g[g[i].end()[-2]].push_back(a[k++] = g[i].back());
      g[i].pop_back();
    }
  reverse(a, a + k);
  cout << 0;
  for (int i = 0; !g[i].empty(); i = g[i][0]) cout << " " << g[i][0];
  cout << '\n';
  cout << k << '\n';
  if (k) cout << a[0];
  for (int i = 1; i < k; i++) cout << " " << a[i];
  cout << '\n';
  return 0;
}
