#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<vector<int>> g(n + 1);
  vector<int> dep(n + 1), len(n + 1), son(n + 1), dfn(n + 1), fa(n + 1);
  for (int i = 2; i <= n; i++) {
    int u;
    cin >> u;
    g[++u].push_back(i);
    fa[i] = u;
  }
  function<void(int)> dfs1 = [&](int x) {
    for (int to : g[x]) {
      dep[to] = dep[x] + 1;
      dfs1(to);
      if (len[son[x]] < len[to]) son[x] = to;
    }
    len[x] = len[son[x]] + 1;
  };
  int tot = 0;
  function<void(int)> dfs2 = [&](int x) {
    dfn[++tot] = x;
    sort(g[x].begin(), g[x].end(),
         [&](int i, int j) { return len[i] < len[j]; });
    for (int to : g[x]) {
      dfs2(to);
    }
  };
  dfs1(1);
  dfs2(1);
  int ans = 0;
  for (int i = 1; i <= n; i++) cout << dfn[i] - 1 << " ";
  cout << endl;
  for (int i = 2; i <= n; i++) ans += dep[dfn[i - 1]] - dep[fa[dfn[i]]];
  cout << ans << endl;
  for (int i = 2; i <= n; i++)
    for (int j = 1; j <= dep[dfn[i - 1]] - dep[fa[dfn[i]]]; j++)
      cout << dfn[i] - 1 << " ";
  cout << endl;
}
