#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> w;
int wgt(int v, int p) {
  if ((v != 1) && (g[v].size() == 1)) {
    w.push_back(1);
    return 1;
  }
  int cw = 0;
  int i;
  for (i = 0; i < g[v].size(); i++) {
    if (g[v][i] == p) continue;
    cw += wgt(g[v][i], v);
  }
  w.push_back(cw);
  return cw;
}
int main(void) {
  int n, m, k, i, j, t, p;
  vector<int> tmp;
  g.clear();
  tmp.clear();
  scanf("%d", &n);
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  for (i = 0; i <= n; i++) {
    g.push_back(tmp);
  }
  for (i = 2; i <= n; i++) {
    scanf("%d", &k);
    g[i].push_back(k);
    g[k].push_back(i);
  }
  p = wgt(1, -1);
  sort(w.begin(), w.end());
  for (i = 0; i < w.size(); i++) printf("%d ", w[i]);
  return 0;
}
