#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > neigh(100005);
long long father[100005], was[100005], sons[100005];
void dfs(long long start, long long fat) {
  father[start] = fat;
  for (long long i = 0; i < neigh[start].size(); i++) {
    if (!father[neigh[start][i]]) dfs(neigh[start][i], start);
  }
}
void dfs(long long start) {
  was[start] = 1;
  long long cnt = 0, i;
  for (i = 0; i < neigh[start].size(); i++) {
    if (!was[neigh[start][i]]) {
      cnt++;
      dfs(neigh[start][i]);
    }
  }
  if (cnt == 0)
    sons[start] = 1;
  else {
    for (i = 0; i < neigh[start].size(); i++) {
      sons[start] += sons[neigh[start][i]];
    }
  }
}
int main() {
  long long n, i;
  cin >> n;
  for (i = 2; i <= n; i++) {
    long long z;
    cin >> z;
    neigh[z].push_back(i);
    neigh[i].push_back(z);
  }
  dfs(1, -1);
  dfs(1);
  vector<long long> a;
  for (i = 1; i <= n; i++) a.push_back(sons[i]);
  sort(a.begin(), a.end());
  for (i = 0; i < a.size(); i++) cout << a[i] << " ";
  return 0;
}
