#include <bits/stdc++.h>
using namespace std;
namespace mine {
long long qread() {
  long long ans = 0, f = 1;
  char c = getchar();
  while (c < '0' or c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c and c <= '9') ans = ans * 10 + c - '0', c = getchar();
  return ans * f;
}
void write(long long num) {
  if (num < 0) putchar('-'), num = -num;
  if (num >= 10) write(num / 10);
  putchar('0' + num % 10);
}
void write1(long long num) {
  write(num);
  putchar(' ');
}
void write2(long long num) {
  write(num);
  putchar('\n');
}
template <typename T>
void chmax(T &x, const T y) {
  x = (x > y ? x : y);
}
template <typename T>
void chmin(T &x, const T y) {
  x = (x < y ? x : y);
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int mm(const int x) { return x >= MOD ? x - MOD : x; }
template <typename T>
void add(T &x, const int &y) {
  x = (x + y >= MOD ? x + y - MOD : x + y);
}
long long qpower(long long x, long long e, int mod = MOD) {
  long long ans = 1;
  if (e < 0) {
    puts("error");
    exit(666);
  }
  while (e) {
    if (e & 1) ans = ans * x % mod;
    x = x * x % mod;
    e >>= 1;
  }
  return ans;
}
long long invm(long long x) { return qpower(x, MOD - 2); }
const int N = 1e6 + 10;
int fa[N];
vector<pair<int, int> > son[N];
int linkfa[N], endpos[N];
vector<int> oper;
void output(int x, int times) {
  while (times--) oper.push_back(x);
}
vector<int> ans;
void main() {
  int n = qread();
  for (int i = (1), I = (n - 1); i <= I; i++) fa[i] = qread();
  for (int x = (n - 1), I = (0); x >= I; x--) {
    sort((son[x]).begin(), (son[x]).end());
    int ln = 1;
    endpos[x] = x;
    if (((int)(son[x]).size())) {
      ln += son[x].back().first;
      linkfa[son[x][0].second] = x;
      for (int t = (1), I = (((int)(son[x]).size()) - 1); t <= I; t++)
        output(son[x][t].second, son[x][t - 1].first),
            linkfa[son[x][t].second] = endpos[son[x][t - 1].second];
      endpos[x] = endpos[son[x].back().second];
    }
    if (x > 0)
      son[fa[x]].push_back(make_pair(ln, x));
    else
      linkfa[0] = -1;
  }
  for (int x = endpos[0]; x >= 0; x = linkfa[x]) ans.push_back(x);
  for (int t = (((int)(ans).size()) - 1), I = (0); t >= I; t--) write1(ans[t]);
  puts("");
  write2(((int)(oper).size()));
  for (auto t : oper) write1(t);
}
};  // namespace mine
signed main() {
  srand(time(0));
  mine::main();
}
