#include <bits/stdc++.h>
using namespace std;
int gcd1(int a, int b) {
  if (a == 0) return b;
  return gcd1(b % a, a);
}
long long modx(long long base, long long ex) {
  long long ans = 1LL, val = base;
  while (ex > 0LL) {
    if (ex & 1LL) ans = (ans * val) % 1000000007;
    val = (val * val) % 1000000007;
    ex = ex >> 1LL;
  }
  return ans;
}
int n;
vector<int> adj[300005];
bool visit[300005];
int cnt[300005];
vector<int> v;
void dfs(int start) {
  visit[start] = true;
  for (int i = 0; i < adj[start].size(); i++) {
    int pt = adj[start][i];
    if (!visit[pt]) {
      dfs(pt);
      cnt[start] += cnt[pt];
    }
  }
  cnt[start] = max(cnt[start], 1);
  v.push_back(cnt[start]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int p;
  for (int i = 2; i <= n; i++) {
    cin >> p;
    adj[p].push_back(i);
    adj[i].push_back(p);
  }
  dfs(1);
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
  return 0;
}
