#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5 + 20;
const long long mod = 1e9 + 7;
const bool debug = false;
template <class T>
inline void add(T &x, long long y, long long mod) {
  x += y;
  if (x >= mod) x -= mod;
}
template <class T>
inline void del(T &x, long long y, long long mod) {
  x -= y;
  if (x < 0) x += mod;
}
template <class T>
inline void add(T &x, long long y, long long z, long long mod) {
  x = y + z;
  if (x >= mod) x -= mod;
}
inline long long qpow(long long x, long long y, long long mod) {
  x %= mod;
  long long ret = 1;
  while (y) {
    if (y & 1) ret = ret * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ret;
}
inline long long qmul(long long x, long long y, long long mod) {
  return ((x * y - (long long)((long double)x * y / mod) * mod) + mod) % mod;
}
inline long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; }
inline long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
int line[N], en, fa[N], deep[N];
stack<int> st;
vector<int> vc[N], ans;
bool cmp(int x, int y) { return deep[x] < deep[y]; }
void bfs(int o) {
  deep[o] = 1;
  for (auto it : vc[o]) {
    bfs(it);
    deep[o] = max(deep[o], deep[it] + 1);
  }
  sort(vc[o].begin(), vc[o].end(), cmp);
}
void dfs(int o) {
  line[++en] = o;
  while (!st.empty() && st.top() != fa[o]) st.pop(), ans.push_back(o);
  st.push(o);
  for (auto it : vc[o]) dfs(it);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1, x; i < n; ++i) {
    scanf("%d", &x);
    vc[x].push_back(i);
    fa[i] = x;
  }
  bfs(0);
  dfs(0);
  for (int i = 1; i <= n; ++i) printf("%d%c", line[i], " \n"[i == n]);
  int si = ans.size();
  printf("%d\n", si);
  for (int i = 0; i < si; ++i) printf("%d%c", ans[i], " \n"[i == si - 1]);
  return 0;
}
