#include <bits/stdc++.h>
using namespace std;
long long n;
vector<vector<long long> > g;
vector<long long> cnt;
vector<bool> used;
void dfs(long long v) {
  used[v] = true;
  bool flag = true;
  for (auto u : g[v]) {
    if (!used[u]) {
      flag = false;
      dfs(u);
      cnt[v] += cnt[u];
    }
  }
  if (flag) cnt[v] = 1;
}
void read() {
  cin >> n;
  g.resize(n);
  for (long long i = 1; i < n; i++) {
    long long x;
    cin >> x;
    x--;
    g[x].push_back(i);
    g[i].push_back(x);
  }
}
void run() {
  cnt.assign(n, 0);
  used.assign(n, false);
  dfs(0);
  sort(cnt.begin(), cnt.end());
}
void write() {
  for (long long i = 0; i < n; i++) cout << cnt[i] << " ";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  read();
  run();
  write();
  return 0;
}
