#include <bits/stdc++.h>
using namespace std;
set<int> al[200001];
int par[200001];
pair<int, int> dfs(int s) {
  pair<int, int> m = {0, s};
  for (auto i = al[s].begin(); i != al[s].end(); ++i) {
    int x = (*i);
    pair<int, int> c = dfs(x);
    if (c.first + 1 > m.first) m = make_pair(c.first + 1, c.second);
  }
  return (m);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int test = 1;
  for (; test > 0; --test) {
    int n, x;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
      cin >> x;
      al[x].insert(i + 1);
      par[i + 1] = x;
    }
    pair<int, int> m = dfs(0);
    int t = n - 1 - m.first, cur = m.second;
    vector<long long int> v, v1;
    v.push_back(cur);
    al[par[cur]].erase(cur);
    while (cur != 0) {
      if (al[par[cur]].size() > 0) break;
      cur = par[cur];
      if (cur != 0) al[par[cur]].erase(cur);
      v.push_back(cur);
    }
    for (int i = 0; i < t + 1; ++i) {
      while (cur != 0) {
        if (al[par[cur]].size() > 0) {
          break;
        }
        cur = par[cur];
        if (cur != 0) al[par[cur]].erase(cur);
        v.push_back(cur);
      }
      if (cur == 0) break;
      v1.push_back(cur);
      par[cur] = *(al[par[cur]].begin());
    }
    reverse((v1).begin(), (v1).end());
    reverse((v).begin(), (v).end());
    for (int i = 0; i < v.size(); ++i) cout << v[i] << ' ';
    cout << '\n' << t << '\n';
    for (int i = 0; i < v1.size(); ++i) cout << v1[i] << ' ';
    cout << '\n';
  }
  return (0);
}
