#include <bits/stdc++.h>
using namespace std;
int par[100001];
vector<int> child[100001];
pair<int, int> counts[100001];
int specialchild[100001];
bool veryspecial[100001];
void dfs1(int x) {
  int counter = 0;
  for (int i : child[x]) {
    dfs1(i);
    counter += counts[i].second;
  }
  int minans = 10000000;
  for (int i : child[x]) {
    int y = counts[i].first - counts[i].second + counter;
    if (y < minans) minans = y, specialchild[x] = i;
  }
  counts[x] = {minans, counter + 1};
  if (child[x].size() == 0) counts[x] = {0, 1};
}
vector<int> ans;
vector<int> currentline;
void dfs2(int x, bool flag) {
  if (flag == 0) veryspecial[x] = 1;
  if (specialchild[x] == 0 && flag == 0) flag = 1;
  if (flag == 0) dfs2(specialchild[x], flag);
  for (int i : child[x]) {
    if (veryspecial[i] == 0) {
      ans.push_back(currentline[currentline.size() - 1]);
      dfs2(i, 1);
    }
  }
  currentline.push_back(x);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> par[i];
    child[par[i]].push_back(i);
  }
  dfs1(0);
  dfs2(0, 0);
  reverse(ans.begin(), ans.end());
  reverse(currentline.begin(), currentline.end());
  for (int i : currentline) cout << i << ' ';
  cout << endl;
  cout << counts[0].first << endl;
  for (int i : ans) cout << i << ' ';
  return 0;
}
