#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
vector<int> id;
vector<int> ans;
vector<int> height;
const int INF = 1e9;
int setHeight(int v, Graph& g) {
  height[v] = 0;
  for (auto to : g[v]) {
    height[v] = max(height[v], setHeight(to, g) + 1);
  }
  return height[v];
}
bool piyo;
void ordDFS(int v, Graph& g) {
  for (auto to : g[v]) ordDFS(to, g);
  sort(g[v].begin(), g[v].end(),
       [&](int lhs, int rhs) { return height[lhs] < height[rhs]; });
}
void dfs(int v, Graph& g) {
  id.push_back(v);
  int pre = -1;
  for (auto to : g[v]) {
    dfs(to, g);
    if (pre != -1) {
      int x = pre;
      while (g[x].size()) {
        ans.push_back(to);
        x = g[x].back();
      }
      ans.push_back(to);
    }
    pre = to;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  Graph g(n);
  height.resize(n);
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    g[p].push_back(i);
  }
  setHeight(0, g);
  piyo = true;
  ordDFS(0, g);
  dfs(0, g);
  for (int i = 0; i < n; i++) cout << id[i] << " ";
  cout << endl;
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
