#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
template <typename _T>
inline void read(_T &f) {
  f = 0;
  _T fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fu = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= fu;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + 48);
  else
    print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
  print(x);
  putchar(t);
}
const int N = 1e5 + 5;
vector<int> adj[N], tr, ans;
int p[N], maxdep[N];
int n;
void dfs(int u) {
  maxdep[u] = 1;
  int id = 0;
  for (register int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    dfs(v);
    if (maxdep[v] + 1 > maxdep[u]) {
      maxdep[u] = maxdep[v] + 1;
      id = i;
    }
  }
  if (adj[u].size()) swap(adj[u][id], adj[u][adj[u].size() - 1]);
}
void dfs1(int u) {
  tr.push_back(u);
  for (register int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    int now = tr[tr.size() - 1];
    while (now != u) {
      ans.push_back(v);
      now = p[now];
    }
    dfs1(v);
  }
}
int main() {
  read(n);
  for (register int i = 2; i <= n; i++) {
    read(p[i]);
    ++p[i];
    adj[p[i]].push_back(i);
  }
  dfs(1);
  dfs1(1);
  for (register int i = 0; i < n; i++) print(tr[i] - 1, ' ');
  putchar('\n');
  print((int)ans.size(), '\n');
  for (register int i = 0; i < (int)ans.size(); i++) print(ans[i] - 1, ' ');
  putchar('\n');
  return 0;
}
