#include <bits/stdc++.h>
using namespace std;
template <typename G>
struct triple {
  G first, second, T;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> par(n);
  vector<vector<int>> tree(n);
  vector<int> depth(n);
  for (int i = 1; i < n; i++) {
    cin >> par[i];
    tree[par[i]].push_back(i);
    depth[i] = depth[par[i]] + 1;
  }
  for (int i = n - 1; i >= 0; i--)
    for (auto &j : tree[i]) depth[i] = max(depth[i], depth[j]);
  for (auto &i : tree)
    sort(i.begin(), i.end(), [&](int x, int y) { return depth[x] < depth[y]; });
  int cur = 0;
  while (!tree[cur].empty()) cur = tree[cur].back();
  vector<int> upd;
  vector<int> ans;
  while (cur > 0) {
    while (tree[par[cur]].size() > 1) {
      int p = par[cur];
      tree[p].pop_back();
      tree[tree[p].back()].push_back(cur);
      par[cur] = tree[p].back();
      upd.push_back(cur);
    }
    ans.push_back(cur);
    cur = par[cur];
  }
  ans.push_back(0);
  reverse(ans.begin(), ans.end());
  reverse(upd.begin(), upd.end());
  for (int i = 0; i < n; i++) cout << ans[i] << " \n"[i == n - 1];
  cout << upd.size() << '\n';
  for (int i = 0; i < upd.size(); i++)
    cout << upd[i] << " \n"[i == upd.size() - 1];
  return 0;
}
