#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
int pr[N];
int n;
vector<int> gr[N];
int sum[N];
void dfs(int v) {
  if (gr[v].size() == 0) {
    sum[v] = 1;
    return;
  }
  for (int to : gr[v]) {
    dfs(to);
    sum[v] += sum[to];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &pr[i]);
    gr[pr[i]].push_back(i);
  }
  dfs(1);
  sort(sum + 1, sum + n + 1);
  for (int i = 1; i <= n; i++) {
    printf("%d ", sum[i]);
  }
}
