#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n;
vector<int> tr[MAXN];
int p[MAXN];
vector<int> order;
vector<int> ops;
int cnt = 0;
int height[MAXN];
int H(int i) {
  int mx = 0;
  for (int j = 0; j < tr[i].size(); j++) {
    mx = max(mx, H(tr[i][j]));
  }
  return height[i] = mx + 1;
}
void dfs(int i) {
  order.push_back(i);
  for (int j = 0; j < cnt; j++) {
    ops.push_back(i);
  }
  cnt = 0;
  int ind = -1;
  for (int j = 0; j < tr[i].size(); j++) {
    if (ind == -1 || height[tr[i][j]] > height[ind]) {
      ind = tr[i][j];
    }
  }
  for (int j = 0; j < tr[i].size(); j++) {
    if (tr[i][j] == ind) continue;
    dfs(tr[i][j]);
  }
  if (ind != -1) dfs(ind);
  cnt++;
}
int main() {
  scanf("%d", &n);
  p[0] = -1;
  for (int i = 1; i < n; i++) {
    scanf("%d", p + i);
    tr[p[i]].push_back(i);
  }
  H(0);
  dfs(0);
  for (int i = 0; i < order.size(); i++) printf("%d ", order[i]);
  printf("\n%d\n", ops.size());
  for (int i = 0; i < ops.size(); i++) {
    printf("%d ", ops[i]);
  }
  printf("\n");
}
