#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
const long long mod = 1e9 + 7;
vector<int> edge[N];
int siz[N];
void dfs(int x) {
  if (edge[x].size() == 0) siz[x] = 1;
  for (auto v : edge[x]) dfs(v), siz[x] += siz[v];
}
int main() {
  int n;
  cin >> n;
  int x;
  for (int i = 2; i <= n; i++) {
    cin >> x;
    edge[x].push_back(i);
  }
  dfs(1);
  sort(siz + 1, siz + 1 + n);
  for (int i = 1; i <= n; i++) printf("%d ", siz[i]);
}
