#include <bits/stdc++.h>
const int N = 1e5 + 1;
const int INF = 1e9 + 9;
int n;
int d[N];
std::vector<int> a[N];
int dfs(int v) {
  for (int u : a[v]) {
    d[v] += dfs(u);
  }
  if (d[v] == 0) return d[v] = 1;
  return d[v];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d", &x);
    x--;
    a[x].push_back(i);
  }
  dfs(0);
  std::sort(d, d + n);
  for (int i = 0; i < n; i++) printf("%d ", d[i]);
}
