#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> adj[N];
bool visi[N];
int dp[N];
void dfs(int s, int par) {
  if (adj[s].size() == 1 && s != 1) dp[s] = 1;
  for (int i = 0; i < adj[s].size(); i++) {
    if (par != adj[s][i]) {
      dfs(adj[s][i], s);
      dp[s] += dp[adj[s][i]];
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x;
    y = i + 1;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  if (n == 1) dp[1] = 1;
  dfs(1, 1);
  sort(dp + 1, dp + n + 1);
  for (int i = 1; i <= n; i++) cout << dp[i] << " ";
  cout << endl;
}
