#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  vector<int> p(n), dep(n);
  vector<set<int>> son(n);
  for (int i = 1; i != n; ++i) {
    cin >> p[i];
    son[p[i]].insert(i);
    dep[i] = dep[p[i]] + 1;
  }
  vector<int> node, bamboo;
  for (int u = max_element(dep.begin(), dep.end()) - dep.begin(); u; u = p[u]) {
    while (int(son[p[u]].size()) != 1) {
      son[p[u]].erase(u);
      son[p[u] = *son[p[u]].begin()].insert(u);
      node.push_back(u);
    }
    bamboo.push_back(u);
  }
  reverse(node.begin(), node.end());
  reverse(bamboo.begin(), bamboo.end());
  cout << "0";
  for (int u : bamboo) cout << " " << u;
  cout << endl << node.size() << endl;
  if (!node.empty()) {
    cout << node[0];
    for (int i = 1; i != int(node.size()); ++i) cout << " " << node[i];
  }
  cout << endl;
}
