#include <bits/stdc++.h>
using namespace std;
int sum[1111111];
int ans[1111111];
int x;
vector<int> e[1111111];
int n;
void dfs(int u, int fa) {
  bool isLeaf = true;
  for (int v : e[u]) {
    if (v != fa) {
      isLeaf = false;
      dfs(v, u);
      sum[u] += sum[v];
    }
  }
  if (isLeaf) sum[u] = 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    e[i].push_back(x);
    e[x].push_back(i);
  }
  dfs(1, 0);
  sort(sum + 1, sum + n + 1);
  for (int i = 1; i <= n; i++) printf("%d ", sum[i]);
  return 0;
}
