#include <bits/stdc++.h>
using namespace std;
int dp[100009];
vector<int> adj[100009];
int vis[100009];
int totleaf;
int calc(int s) {
  vis[s] = 1;
  int lf = 0, loc = 0;
  for (int i = 0; i < adj[s].size(); i++) {
    if (!vis[adj[s][i]]) {
      loc = 1;
      lf += calc(adj[s][i]);
    }
  }
  if (!loc) lf += 1;
  dp[s] = lf;
  return lf;
}
int main() {
  int n;
  while (cin >> n) {
    memset(vis, 0, sizeof(vis));
    for (int i = 2; i <= n; i++) {
      int v;
      cin >> v;
      adj[i].push_back(v);
      adj[v].push_back(i);
    }
    totleaf = 0;
    calc(1);
    sort(dp + 1, dp + n + 1);
    for (int i = 1; i <= n; i++) {
      cout << dp[i] << " ";
    }
    cout << endl;
    for (int i = 1; i <= n; i++) {
      adj[i].clear();
    }
  }
}
