#include <bits/stdc++.h>
using namespace std;
long long a[1234567], b[1234567], c, d, e, f, i, j, n, l, r;
multiset<long long> ms;
vector<long long> v[123456];
string s;
int rec(int p) {
  int ans = 0;
  for (int i = 0; i < v[p].size(); i++) {
    ans += rec(v[p][i]);
  }
  if (ans == 0) ans = 1;
  return b[p] = ans;
}
int main() {
  ios_base::sync_with_stdio();
  cin.tie();
  cout.tie();
  cin >> c;
  for (i = 2; i <= c; i++) {
    cin >> a[i];
    v[a[i]].push_back(i);
  }
  rec(1);
  sort(b + 1, b + c + 1);
  for (i = 1; i <= c; i++) {
    cout << b[i] << " ";
  }
}
