#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> g[100005];
int padre[100005];
vector<int> leafs;
int pingo[100005];
int ojete[100005];
int sumpar[100005];
bool vis[100005];
int dfs(int j) {
  if (j != 1 && g[j].size() == 1) return pingo[j] = 1;
  if (vis[j])
    return pingo[j];
  else {
    vis[j] = true;
    int counter = 0;
    for (auto v : g[j]) {
      counter += dfs(v);
    }
    return pingo[j] = counter;
  }
}
int main() {
  scanf("%lld", &n);
  if (n == 1) {
    puts("1");
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    padre[i] = p;
    g[p].push_back(i);
    g[i].push_back(p);
  }
  for (int i = 2; i <= n; i++) {
    if (g[i].size() == 1) leafs.push_back(i);
  }
  int a = dfs(1);
  for (int i = 1; i <= n; i++) {
    ojete[pingo[i]]++;
  }
  for (int i = 1; i <= n + 1; i++) {
    sumpar[i] = sumpar[i - 1] + ojete[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    int d = lower_bound(sumpar, sumpar + n + 1, i) - sumpar;
    printf("%d ", d - 1);
  }
  puts("");
  return 0;
}
