#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
vector<int> son[N], ans;
int h[N], fa[N], n;
void dfs1(int u) {
  h[u] = 0;
  for (auto v : son[u]) {
    dfs1(v);
    h[u] = max(h[u], h[v]);
  }
  ++h[u];
}
void dfs2(int u) {
  vector<int> &nx = son[u];
  if (nx.size() == 0) return;
  if (nx.size() > 1) {
    int ks = 0;
    for (int i = 1; i < nx.size(); ++i)
      if (h[nx[i]] > h[nx[ks]]) ks = i;
    swap(nx[0], nx[ks]);
    for (int i = 0; i + 1 < nx.size(); ++i) {
      ans.push_back(nx[i]);
      son[nx[i + 1]].push_back(nx[i]);
      h[nx[i + 1]] = h[nx[i]] + 1;
    }
    nx.erase(nx.begin(), nx.end() - 1);
  }
  dfs2(nx[0]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d", &fa[i]);
    son[fa[i]].push_back(i);
  }
  dfs1(0);
  dfs2(0);
  for (int u = 0;; u = son[u][0]) {
    printf("%d ", u);
    if (son[u].size() == 0) break;
  }
  printf("\n%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[ans.size() - 1 - i]);
  return 0;
}
