#include <bits/stdc++.h>
using namespace std;
vector<int> v[100100];
int kolko[100100];
bool bio[100100];
int dfs(int x) {
  if (v[x].size() == 1 && bio[v[x][0]]) return kolko[x] = 1;
  bio[x] = 1;
  int sol = 0;
  for (int i = 0; i < v[x].size(); i++)
    if (!bio[v[x][i]]) sol += dfs(v[x][i]);
  return kolko[x] = sol;
}
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "1\n";
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    v[x].push_back(i);
    v[i].push_back(x);
  }
  dfs(1);
  sort(kolko + 1, kolko + n + 1);
  for (int i = 1; i <= n; i++) cout << kolko[i] << " ";
  return 0;
}
