#include <bits/stdc++.h>
using namespace std;
const int inf = (long long)1e9;
const int mod = inf + 7;
int n;
int sz[100300];
vector<int> g[100300];
void dfs(int v, int p) {
  if ((int)g[v].size() == 1 && p != 0) sz[v] = 1;
  for (int i = 0; i < (int)g[v].size(); ++i) {
    int to = g[v][i];
    if (to == p) continue;
    dfs(to, v);
    sz[v] += sz[to];
  }
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  if (n == 1) {
    cout << 1 << "\n";
    return 0;
  }
  for (int i = 2; i <= n; ++i) {
    int p;
    cin >> p;
    g[p].push_back(i);
    g[i].push_back(p);
  }
  dfs(1, 0);
  sort(sz + 1, sz + n + 1);
  for (int i = 1; i <= n; ++i) {
    cout << sz[i] << " ";
  }
  return 0;
}
