#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = 1e6;
struct node {
  int to, next;
};
node edge[maxm];
int head[maxn], tot;
void add_edge(int u, int v) {
  edge[tot].to = v;
  edge[tot].next = head[u];
  head[u] = tot++;
}
void init_edge() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
int p[maxn], ans[maxn];
void dfs(int u) {
  if (head[u] == -1) {
    ans[u] = 1;
    return;
  }
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].to;
    dfs(v);
    ans[u] += ans[v];
  }
}
int main() {
  int n;
  cin >> n;
  init_edge();
  for (int i = 2; i <= n; i++) {
    cin >> p[i];
    add_edge(p[i], i);
  }
  dfs(1);
  sort(ans + 1, ans + 1 + n);
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
