#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100002];
int sz[100002];
void dfs(int s, int p) {
  if (1 == adj[s].size() && s != 1) {
    sz[s]++;
  }
  for (int node : adj[s]) {
    if (node == p) continue;
    dfs(node, s);
    sz[s] += sz[node];
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int p;
    cin >> p;
    adj[i].push_back(p);
    adj[p].push_back(i);
  }
  dfs(1, 0);
  sort(sz + 1, sz + 1 + n);
  if (n == 1) sz[1] = 1;
  for (int i = 1; i <= n; i++) cout << sz[i] << " ";
  cout << "\n";
  return 0;
}
