#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<vector<int>> g(n);
  vector<int> p(n, -1);
  for (int i = 1; i < n; i++) {
    int u;
    cin >> u;
    g[u].push_back(i);
    p[i] = u;
  }
  vector<vector<int>> dp(2, vector<int>(n));
  vector<int> res;
  vector<int> sp(n, INT_MAX);
  vector<int> cs(n, -1);
  vector<int> to(n, -1);
  function<void(int)> dfs = [&](int v) {
    if (g[v].empty()) {
      dp[0][v] = 0;
      dp[1][v] = 0;
      sp[v] = 0;
      return;
    }
    int dif = 0;
    to[v] = -1;
    for (int u : g[v]) {
      dfs(u);
      dp[1][v] += dp[1][u] + 1;
      if (dif > dp[0][u] - dp[1][u] - 1) to[v] = u;
      dif = min(dif, dp[0][u] - dp[1][u] - 1);
      if (sp[u] + 1 < sp[v]) cs[v] = u;
      sp[v] = min(sp[u] + 1, sp[v]);
    }
    dp[0][v] = dp[1][v] + dif;
  };
  dfs(0);
  vector<int> ans;
  function<void(int, bool)> dfs2 = [&](int v, bool cover) {
    ans.push_back(v);
    if (cover) {
      for (int i = 0; i < (int)g[v].size(); i++)
        if (g[v][i] == cs[v]) swap(g[v][i], g[v].back());
    } else {
      for (int i = 0; i < (int)g[v].size(); i++)
        if (g[v][i] == to[v]) swap(g[v][i], g[v].back());
    }
    for (int u : g[v]) {
      if (!cover) {
        if (u == to[v])
          dfs2(u, false);
        else
          dfs2(u, true);
      } else
        dfs2(u, true);
    }
    for (int i = 1; i < (int)g[v].size(); i++) {
      for (int j = 0; j < sp[g[v][i - 1]] + 1; j++) res.push_back(g[v][i]);
    }
  };
  dfs2(0, false);
  for (int i : ans) cout << i << " ";
  cout << endl;
  cout << res.size() << endl;
  for (int i : res) cout << i << " ";
  return 0;
}
