#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 1; i < n; ++i) cin >> p[i];
  vector<vi> ch(n);
  for (int i = 1; i < n; ++i) ch[p[i]].push_back(i);
  vector<int> depth(n);
  for (int i = n - 1; i > 0; --i) depth[p[i]] = max(depth[p[i]], 1 + depth[i]);
  vector<int> instr;
  vector<int> init;
  function<void(int)> dfs1 = [&](int u) {
    init.push_back(u);
    int k = (int)(ch[u]).size();
    for (int j = 0; j < k - 1; ++j) {
      if (depth[ch[u][j]] > depth[ch[u][k - 1]]) swap(ch[u][j], ch[u][k - 1]);
    }
    for (int v : ch[u]) dfs1(v);
  };
  dfs1(0);
  int k = 0;
  assert((int)(init).size() == n);
  function<void(int)> dfs2 = [&](int u) {
    ++k;
    for (int v : ch[u]) dfs2(v);
    if (k < n) {
      instr.push_back(init[k]);
    }
  };
  dfs2(0);
  for (int i = 0; i < n; ++i) {
    cout << init[i];
    if (i == n - 1)
      cout << "\n";
    else
      cout << " ";
  }
  cout << (int)(instr).size() << "\n";
  for (int x : instr) {
    cout << x << " ";
  }
  cout << endl;
}
