#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int dad[N], n;
vector<int> ad[N];
vector<int> brg[N];
int dp[N];
int cnt(int v) {
  if (ad[v].size() == 0) {
    dp[v] = 1;
    return 1;
  }
  for (int i = 0; i < ad[v].size(); i++) {
    cnt(ad[v][i]);
    dp[v] += dp[ad[v][i]];
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> dad[i];
    dad[i]--;
    ad[dad[i]].push_back(i);
  }
  cnt(0);
  sort(dp, dp + n);
  for (int i = 0; i < n; i++) cout << dp[i] << " ";
  return 0;
}
