#include <bits/stdc++.h>
using namespace std;
const long long NMAX = 1000001;
vector<int> v[NMAX];
int tobehappy[NMAX];
void DFS(int node) {
  if (v[node].size() == 0) tobehappy[node] = 1;
  for (auto x : v[node]) {
    DFS(x);
    tobehappy[node] += tobehappy[x];
  }
}
int main() {
  int n, i;
  cin >> n;
  for (i = 2; i <= n; i++) {
    int x, y;
    cin >> y;
    v[y].push_back(i);
  }
  DFS(1);
  sort(tobehappy + 1, tobehappy + n + 1);
  for (i = 1; i <= n; i++) cout << tobehappy[i] << " ";
  return 0;
}
