#include <bits/stdc++.h>
using namespace std;
int N;
int Move[100005], cnt, P[100005];
vector<int> G[100005];
int TT[100005], Next[100005];
int DP[100005], Stack[100005], top;
void Read() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    int father;
    scanf("%d", &father);
    ++father;
    G[father].push_back(i + 1);
    TT[i + 1] = father;
  }
}
void DFS(int node) {
  for (int i = 0; i < G[node].size(); i++) {
    int neighb = G[node][i];
    DFS(neighb);
    DP[node] = max(DP[node], DP[neighb] + 1);
  }
}
void precalcPath() {
  int node = 1;
  while (G[node].size() != 0) {
    Stack[++top] = node;
    for (int i = 0; i < G[node].size(); i++) {
      int neighb = G[node][i];
      if (DP[neighb] == DP[node] - 1) {
        swap(G[node][i], G[node][G[node].size() - 1]);
        G[node].pop_back();
        node = neighb;
        break;
      }
    }
  }
  Stack[++top] = node;
}
void Solve(int node, int next) {
  int last = next;
  for (int i = 0; i < G[node].size(); i++) {
    int neighb = G[node][i];
    TT[last] = neighb;
    Move[++cnt] = last;
    last = neighb;
  }
  for (int i = G[node].size() - 1; i >= 1; i--)
    Solve(G[node][i], G[node][i - 1]);
  if (G[node].size() > 0) Solve(G[node][0], next);
}
void printSol() {
  int node = 1;
  for (int i = 1; i <= N; i++) Next[TT[i]] = i;
  for (int i = 1; i <= N; i++) {
    printf("%d ", node - 1);
    node = Next[node];
  }
  printf("\n%d\n", cnt);
  for (int i = cnt; i >= 1; i--) printf("%d ", Move[i] - 1);
  printf("\n");
}
int main() {
  Read();
  DFS(1);
  precalcPath();
  for (int i = 1; i < top; i++) Solve(Stack[i], Stack[i + 1]);
  printSol();
  return 0;
}
