#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 100 + 4;
int n;
int l[MAXN], par[MAXN];
int cnt[MAXN];
vector<int> adj[MAXN];
void dfs(int u) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v != par[u]) {
      par[v] = u;
      dfs(v);
      l[u] += l[v];
    }
  }
  if (u != 0 && adj[u].size() == 1) {
    l[u]++;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int x;
    cin >> x;
    x--;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  dfs(0);
  sort(l, l + n);
  if (n == 1)
    cout << 1 << endl;
  else {
    for (int i = 1; i <= n; i++) {
      cout << l[i - 1] << endl;
    }
  }
  return 0;
}
