#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int power(long long int a, long long int n) {
  if (n == 0) return 1;
  long long int p = power(a, n / 2);
  p = (p * p) % MOD;
  if (n % 2)
    return (p * a) % MOD;
  else
    return p % MOD;
}
const int N = 200001;
bool visited[N] = {false};
vector<long long int> edges[N];
vector<long long int> ans(N, 0);
long long int dfs(long long int start) {
  visited[start] = true;
  for (auto x : edges[start]) {
    if (!visited[x]) {
      ans[start] += dfs(x);
    }
  }
  if (ans[start]) {
    return ans[start];
  } else {
    ans[start] = 1;
    return 1;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long int test = 1;
  while (test--) {
    long long int n;
    cin >> n;
    for (long long int i = 2; i <= n; i++) {
      long long int u;
      cin >> u;
      edges[u].push_back(i);
      edges[i].push_back(u);
    }
    for (long long int i = 1; i <= n; i++) {
      if (!visited[i]) {
        dfs(i);
      }
    }
    sort(ans.begin() + 1, ans.begin() + n + 1);
    for (long long int i = 1; i <= n; i++) {
      cout << ans[i] << " ";
    }
  }
  return 0;
}
