#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int chi[N], ans[N], mx;
vector<int> adj[N];
map<int, int> mp;
void dfs(int x, int par) {
  for (auto w : adj[x]) {
    if (w == par) continue;
    dfs(w, x);
    chi[x] += chi[w];
  }
  if (chi[x] == 0) chi[x]++;
  mx = max(mx, chi[x]);
  mp[chi[x]]++;
}
void solve() {
  int n, x;
  cin >> n;
  for (int i = 2; i < n + 1; i++) {
    cin >> x;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  dfs(1, 0);
  int i = 2;
  while (i <= mx) {
    mp[i] += mp[i - 1];
    i++;
  }
  int j = 1;
  for (int i = 1; i < n + 1; i++) {
    if (i <= mp[j] && ans[i] == 0) ans[i] = j;
    if (i == mp[j]) {
      j++;
      i--;
    }
    if (i == n) break;
  }
  for (int i = 1; i < n + 1; i++) cout << ans[i] << " ";
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
