#include <bits/stdc++.h>
using namespace std;
int N, ans, dep[100001], tot, id[100001], pos[100001], len[100001];
vector<int> E[100001];
bool cmp(int x, int y) { return len[x] > len[y]; }
int get() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
void put(int x) {
  if (x >= 10) put(x / 10);
  putchar(x % 10 + '0');
}
void dfs1(int u) {
  int l = 0;
  for (auto v : E[u]) dep[v] = dep[u] + 1, dfs1(v), l = max(l, len[v]);
  sort(E[u].begin(), E[u].end(), cmp);
  len[u] = l + 1;
}
void dfs2(int u) {
  id[tot] = u, pos[u] = tot++;
  int M = E[u].size();
  for (int i = M - 1; i >= 0; i--) dfs2(E[u][i]);
}
int main() {
  N = get();
  for (int i = 1; i <= N - 1; i++) E[get()].push_back(i);
  dfs1(0);
  dfs2(0);
  for (int i = 0; i <= N - 1; i++) cout << id[i] << ' ';
  cout << endl;
  for (int i = 1; i <= N - 1; i++) ans += dep[id[i - 1]] - dep[id[i]] + 1;
  cout << ans << endl;
  for (int i = 1; i <= N - 1; i++)
    for (int j = 1; j <= dep[id[i - 1]] - dep[id[i]] + 1; j++)
      cout << id[i] << ' ';
  cout << endl;
  return 0;
}
