#include <bits/stdc++.h>
using namespace std;
pair<int, int> dfs(const vector<vector<int>> &G, int v, vector<int> &N) {
  int s = 0, l = v;
  vector<pair<pair<int, int>, int>> t;
  for (auto v_ : G[v]) {
    auto r = dfs(G, v_, N);
    s = max(s, r.first);
    t.emplace_back(r, v_);
  }
  sort(t.begin(), t.end());
  if (!t.empty()) {
    l = t.back().first.second;
    N[v] = t[0].second;
  }
  for (size_t i = 0; i < t.size(); ++i) {
    if (i + 1 < t.size()) {
      N[t[i].first.second] = t[i + 1].second;
    }
  }
  ++s;
  return {s, l};
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> G(n);
  vector<int> P(n);
  for (int i = 1; i < n; ++i) {
    int p;
    cin >> p;
    P[i] = p;
    G[p].push_back(i);
  }
  vector<int> N(n, -1);
  dfs(G, 0, N).second;
  vector<int> A(n, -1);
  int v = 0;
  cout << v;
  A[0] = v;
  for (int i = 1; i < n; ++i) {
    v = N[v];
    A[i] = v;
    cout << " " << v;
  }
  cout << endl;
  vector<int> Q(n);
  for (int i = 1; i < n; ++i) Q[A[i]] = A[i - 1];
  vector<int> V;
  for (int i = 1; i < n; ++i) {
    while (Q[A[i]] != P[A[i]]) {
      V.push_back(A[i]);
      Q[A[i]] = Q[Q[A[i]]];
    }
  }
  cout << V.size() << endl;
  for (auto e : V) cout << e << " ";
  cout << endl;
}
