#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return x * f;
}
const int N = 1e5 + 5;
vector<int> G[N];
vector<int> ans, ord;
int dep[N], p[N], son[N], num;
void dfs(int u) {
  ans.push_back(u);
  for (int i = 1; i < num; ++i) ord.push_back(u);
  num = 1;
  for (int v : G[u])
    if (v != son[u]) dfs(v);
  if (son[u]) dfs(son[u]);
  ++num;
}
int main() {
  int n = read();
  dep[0] = 1;
  for (int i = 1; i < n; ++i) {
    p[i] = read();
    G[p[i]].push_back(i);
    dep[i] = dep[p[i]] + 1;
  }
  int u = max_element(dep, dep + n) - dep;
  for (; u; u = p[u]) son[p[u]] = u;
  dfs(0);
  for (int i : ans) printf("%d ", i);
  puts("");
  printf("%d\n", ord.size());
  for (int i : ord) printf("%d ", i);
  puts("");
  return 0;
}
