#include <bits/stdc++.h>
using namespace std;
vector<int> adj[(int)1e5 + 100];
int p[(int)1e5 + 100];
int c[(int)1e5 + 100] = {0};
int setchild(int v) {
  if (!adj[v].size()) {
    c[v] = 1;
    return 1;
  }
  for (int i = 0; i < adj[v].size(); i++) c[v] += setchild(adj[v][i]);
  return c[v];
}
int main() {
  int n;
  cin >> n;
  p[1] = -1;
  for (int i = 2; i <= n; i++) {
    cin >> p[i];
    adj[p[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++)
    if (!adj[i].size()) c[i] = 1;
  c[1] = setchild(1);
  sort(c + 1, c + n + 1);
  for (int i = 1; i <= n; i++) cout << c[i] << ' ';
}
