#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);
int n;
vector<vector<int> > g, g2;
int p[N];
vector<int> op;
vector<int> sz;
vector<int> depth;
void dfs(int node, int depth = 0) {
  ::depth[node] = depth;
  if (g[node].size() == 0) {
    sz[node] = 1;
    return;
  }
  for (int i = 0; i < g[node].size(); i++) {
    dfs(g[node][i], depth + 1);
    ::depth[node] = max(::depth[node], ::depth[g[node][i]]);
    sz[node] += sz[g[node][i]];
  }
  sz[node]++;
}
bool cmp(int x, int y) { return depth[x] < depth[y]; }
int idx[N], idx2[N];
void dfs2(int node) {
  if (g[node].empty()) return;
  sort(g[node].begin(), g[node].end(), cmp);
  int t = 0;
  for (int cur, i = 0; i < g[node].size(); i++) {
    cur = idx2[node] + t + 1;
    while (p[cur] != idx2[node]) {
      op.push_back(cur);
      p[cur] = p[p[cur]];
    }
    idx2[g[node][i]] = cur;
    idx[cur] = g[node][i];
    t += sz[g[node][i]];
    dfs2(g[node][i]);
  }
}
int main() {
  cin >> n;
  g.resize(n);
  depth.resize(n);
  g2.resize(n);
  sz.resize(n);
  for (int x, i = 1; i < n; i++) {
    p[i] = i - 1;
    scanf("%d", &x);
    g[x].push_back(i);
  }
  dfs(0);
  dfs2(0);
  for (int i = 0; i < n; i++) {
    cout << idx[i] << ' ';
  }
  cout << endl;
  cout << op.size() << endl;
  for (int i = 0; i < op.size(); i++) {
    cout << idx[op[i]] << ' ';
  }
  return 0;
}
