#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int N = 1e5 + 20;
int n, h[N], maxh[N];
vector<int> g[N];
inline bool cmp(int x, int y) { return maxh[x] < maxh[y]; }
void pre_dfs(int v) {
  maxh[v] = h[v];
  for (int u : g[v]) {
    h[u] = h[v] + 1;
    pre_dfs(u);
    maxh[v] = max(maxh[v], maxh[u]);
  }
  sort(g[v].begin(), g[v].end(), cmp);
}
int per[N], sz;
vector<int> vec;
void dfs(int v) {
  per[sz++] = v;
  for (int u : g[v]) dfs(u);
  int last = h[v];
  for (int u : g[v]) {
    for (int i = 0; i < last - h[v]; i++) vec.push_back(u);
    last = maxh[u];
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1, p; i < n; i++) {
    cin >> p;
    g[p].push_back(i);
  }
  pre_dfs(0);
  dfs(0);
  for (int i = 0; i < n; i++) cout << per[i] << ' ';
  cout << '\n';
  cout << (int)vec.size() << '\n';
  for (int x : vec) cout << x << ' ';
  cout << '\n';
}
