#include <bits/stdc++.h>
using namespace std;
const int NMax = 100005;
int viz[NMax], frunze[NMax], a[NMax];
int n;
vector<int> G[NMax];
void dfs(int nod) {
  viz[nod] = 1;
  if (G[nod].size() == 1 && nod != 1) {
    frunze[nod] = 1;
  }
  for (int i = 0; i < G[nod].size(); ++i) {
    if (!viz[G[nod][i]]) {
      dfs(G[nod][i]);
      frunze[nod] += frunze[G[nod][i]];
    }
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  if (n == 1) {
    cout << 1 << '\n';
    return 0;
  }
  for (int i = 2; i <= n; ++i) {
    cin >> a[i];
    G[i].push_back(a[i]);
    G[a[i]].push_back(i);
  }
  dfs(1);
  sort(frunze + 1, frunze + 1 + n);
  for (int i = 1; i <= n; ++i) {
    cout << frunze[i] << ' ';
  }
  return 0;
}
