#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, i, j, ii, jj, zx, xc, nxt[100009], p[1000009], pi,
    msh[100009], dep[100009], ppi;
vector<int> v[100009];
pair<int, int> pp[100009];
void dfsst(int q) {
  dep[q] = 1;
  for (vector<int>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    dfsst((*it));
    dep[q] = max(dep[q], dep[(*it)] + 1);
  }
}
void dfs(int q) {
  if (v[q].size() == 0) {
    nxt[q] = -1;
    return;
  }
  ppi = 0;
  for (vector<int>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    ppi++;
    pp[ppi].first = dep[(*it)];
    pp[ppi].second = (*it);
  }
  sort(pp + 1, pp + ppi + 1);
  for (i = ppi; i > 1; i--) {
    pi++;
    p[pi] = pp[i].second;
    dep[pp[i - 1].second] = dep[pp[i].second] + 1;
    v[pp[i - 1].second].push_back(pp[i].second);
  }
  nxt[q] = pp[1].second;
  dfs(pp[1].second);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> a;
  for (i = 1; i < a; i++) {
    cin >> c;
    v[c].push_back(i);
    msh[i] = c;
  }
  dfsst(0);
  dfs(0);
  cout << 0;
  c = 0;
  while (1) {
    c = nxt[c];
    if (c == -1) break;
    cout << " " << c;
  }
  cout << endl;
  cout << pi << endl;
  for (i = pi; i >= 1; i--) {
    cout << p[i] << " ";
  }
  return 0;
}
