#include <bits/stdc++.h>
using namespace std;
const int mxx = 100001;
vector<int> adj[mxx];
multiset<int> st;
int n, temp, rnk[mxx];
int dfs(int u) {
  int subs = 1;
  for (auto v : adj[u]) subs += dfs(v);
  if (subs > 1)
    rnk[u] = subs - 1;
  else
    rnk[u] = subs;
  st.insert(rnk[u]);
  return rnk[u];
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 2; i < n + 1; i++) {
    cin >> temp;
    adj[temp].push_back(i);
  }
  dfs(1);
  for (auto i : st) cout << i << " ";
}
