#include <bits/stdc++.h>
using namespace std;
const long long int MAX2 = 105;
const long long int MAX3 = 1005;
const long long int MAX4 = 10005;
const long long int MAX5 = 100005;
const long long int MAX6 = 1000005;
const long long int MAX7 = 10000005;
long long int n;
vector<long long int> g[MAX5], dp;
long long int dfs(long long int u, long long int parent) {
  for (auto v : g[u]) {
    if (v != parent) {
      long long int ans = dfs(v, u);
      dp[u] += ans;
    }
  }
  if (g[u].size() == 1 and u != 1) dp[u] = 1;
  return dp[u];
}
void solve() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    long long int temp;
    cin >> temp;
    ;
    g[i + 1].push_back(temp);
    g[temp].push_back(i + 1);
  }
  if (n == 1) {
    cout << 1;
    return;
  }
  dp.resize(n + 1);
  dfs(1, -1);
  sort(dp.begin(), dp.end());
  for (int i = 1; i < n + 1; i++) {
    cout << dp[i] << " ";
  }
}
int main() {
  int t;
  t = 1;
  cin.sync_with_stdio(0), cin.tie(0);
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
