#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> son[100011];
int height[100011];
void dfs(int x) {
  for (int i = 0; i < son[x].size(); ++i) {
    dfs(son[x][i]);
    height[x] = max(height[son[x][i]], height[x]);
  }
  height[x]++;
  return;
}
vector<int> mov;
void solve(int x) {
  if (son[x].size() == 0)
    return;
  else if (son[x].size() == 1)
    solve(son[x][0]);
  else {
    int mxId = -1, lastId;
    for (int i = 0; i < son[x].size(); ++i) {
      if (mxId == -1 || height[son[x][mxId]] < height[son[x][i]]) {
        mxId = i;
      }
    }
    lastId = mxId;
    for (int i = 0; i < son[x].size(); ++i) {
      if (i == mxId) continue;
      son[son[x][i]].push_back(son[x][lastId]);
      height[son[x][i]] = max(height[son[x][i]], height[son[x][lastId]] + 1);
      mov.push_back(son[x][lastId]);
      lastId = i;
    }
    int sonId = son[x][lastId];
    son[x].clear();
    son[x].push_back(sonId);
    solve(sonId);
  }
}
int main() {
  int tmp;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d", &tmp);
    son[tmp].push_back(i);
  }
  dfs(0);
  int step = n - height[0];
  solve(0);
  tmp = 0;
  for (int i = 0; i < n; ++i) {
    printf("%d ", tmp);
    if (i < n - 1) tmp = son[tmp][0];
  }
  printf("\n%d\n", step);
  for (int i = mov.size() - 1; i >= 0; --i) printf("%d ", mov[i]);
}
