#include <bits/stdc++.h>
using namespace std;
vector<int> G[100005];
bool vis[100005];
int dp[100005];
int child = 0;
int del = 0;
int dfs(int node = 1, int lvl = 0) {
  vis[node] = 1;
  int nos = 1;
  for (auto i : G[node]) {
    if (!vis[i]) {
      nos += dfs(i, lvl + 1);
      dp[node] += dp[i];
    }
  }
  if (G[node].size() == 1 && node != 1) {
    dp[node] = 1;
  }
  return nos;
}
int main() {
  long long int tc = 1;
  while (tc--) {
    int N;
    cin >> N;
    if (N == 1) {
      cout << 1 << "\n";
      return 0;
    }
    int X;
    for (int i = 2; i <= N; i++) {
      cin >> X;
      G[X].push_back(i);
      G[i].push_back(X);
    }
    for (int i = 0; i <= N; i++) {
      vis[i] = 0;
      dp[i] = 0;
    }
    dfs();
    sort(dp + 1, dp + N + 1);
    for (int i = 1; i <= N; i++) {
      cout << dp[i] << " ";
    }
    cout << "\n";
  }
  return 0;
}
