#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  vector<int> par(N, -1);
  vector<set<int>> children(N, set<int>());
  for (int i = 1; i < N; ++i) {
    scanf("%d", &par[i]);
    children[par[i]].insert(i);
  }
  vector<int> bfs = {0};
  for (int i = 0; i < bfs.size(); ++i) {
    bfs.insert(bfs.end(), children[bfs[i]].begin(), children[bfs[i]].end());
  }
  vector<int> order;
  vector<int> ops;
  int cur = bfs.back();
  while (cur != 0) {
    int p = par[cur];
    if (children[p].size() == 1) {
      order.push_back(cur);
      cur = p;
    } else {
      ops.push_back(cur);
      children[p].erase(cur);
      int sibling = *children[p].begin();
      par[cur] = sibling;
      children[sibling].insert(cur);
    }
  }
  order.push_back(0);
  for (int i = N - 1; i >= 0; --i) {
    printf("%d", order[i]);
    if (i == 0)
      printf("\n");
    else
      printf(" ");
  }
  printf("%d\n", (int)ops.size());
  for (int i = ops.size() - 1; i >= 0; --i) {
    printf("%d", ops[i]);
    if (i == 0)
      printf("\n");
    else
      printf(" ");
  }
  return 0;
}
