#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> tree;
vector<pair<int, int>> cnt_sbl;
vector<int> ans;
void dfs_1(int v, int p) {
  cnt_sbl[v].first = 1;
  cnt_sbl[v].second = (tree[v].size() == 1 && p != -1);
  for (int i = 0; i < tree[v].size(); ++i) {
    if (tree[v][i] == p) continue;
    dfs_1(tree[v][i], v);
    cnt_sbl[v].first += cnt_sbl[tree[v][i]].first;
    cnt_sbl[v].second += cnt_sbl[tree[v][i]].second;
  }
}
void dfs_2(int v, int p) {
  ans[cnt_sbl[v].second]++;
  for (auto it : tree[v])
    if (it != p) dfs_2(it, v);
}
int main() {
  int n;
  cin >> n;
  tree.resize(n);
  cnt_sbl.resize(n);
  for (int i = 0; i < n - 1; ++i) {
    int x;
    cin >> x;
    tree[x - 1].push_back(i + 1);
    tree[i + 1].push_back(x - 1);
  }
  if (n == 1) {
    cout << 1;
    return 0;
  }
  dfs_1(0, -1);
  ans.resize(cnt_sbl[0].second + 1);
  dfs_2(0, -1);
  for (int i = 2; i < ans.size(); i++) ans[i] += ans[i - 1];
  int j = 0;
  for (int i = 1; i < ans.size(); ++i) {
    for (; j < ans[i]; j++) cout << i << ' ';
  }
}
