#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void ckmin(T& a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void ckmax(T& a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
using VI = vector<int>;
void dfs(int p, const vector<VI>& g, const VI& w, VI& que) {
  que.push_back(p);
  for (int b = 0; b < (2); ++b)
    for (int x : g[p])
      if (w[x] == b) dfs(x, g, w, que);
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  while (cin >> n) {
    VI p(n);
    p[0] = -1;
    for (int i = (1); i < (n); ++i) cin >> p[i];
    VI d(n);
    for (int i = (1); i < (n); ++i) d[i] = d[p[i]] + 1;
    int key = max_element(d.begin(), d.end()) - d.begin();
    VI w(n);
    for (int x = key; x >= 0; x = p[x]) w[x] = 1;
    vector<VI> g(n);
    for (int i = (1); i < (n); ++i) g[p[i]].push_back(i);
    VI q;
    dfs(0, g, w, q);
    assert(q.back() == key);
    for (int i = 0; i < (n); ++i) printf("%d ", q[i]);
    printf("\n");
    VI ret;
    for (int i = (1); i < (n); ++i)
      for (int k = 0; k < (d[q[i - 1]] - d[p[q[i]]]); ++k) ret.push_back(q[i]);
    printf("%d\n", ((int)ret.size()));
    for (int i = 0; i < (((int)ret.size())); ++i) printf("%d ", ret[i]);
    printf("\n");
    break;
  }
  return 0;
}
