#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007;
constexpr ll INF = (1LL << 61) - 1;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
void fail(T v) {
  cout << v << endl;
  exit(0);
}
vector<int> nxt[101010], ord, res, ch;
void child(int i) {
  for (int e : nxt[i]) {
    child(e);
    chmax(ch[i], ch[e]);
  }
  ch[i]++;
}
void dfs(int i) {
  ord.push_back(i);
  sort(nxt[i].begin(), nxt[i].end(),
       [&](int& a, int& b) { return ch[a] < ch[b]; });
  int now = 0;
  for (int e : nxt[i]) {
    dfs(e);
    for (int j = 0; j < (int)(now); ++j) res.push_back(e);
    now = ch[e];
  }
}
void solve() {
  int N;
  cin >> N;
  for (int i = 0; i < (int)(N - 1); ++i) {
    int p;
    cin >> p;
    nxt[p].push_back(i + 1);
  }
  ch.assign(N, 0);
  child(0);
  dfs(0);
  for (int i = 0; i < (int)(N); ++i) cout << ord[i] << " ";
  cout << endl;
  cout << res.size() << endl;
  for (int i = 0; i < (int)(res.size()); ++i) cout << res[i] << " ";
  cout << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}
