#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  int n;
  cin >> n;
  vector<vector<int> > tree(n);
  vector<int> ans(n);
  tree[0].push_back(0);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    tree[a].push_back(i);
    tree[i].push_back(a);
  }
  function<int(int, int)> dfs = [&](int curr, int last) {
    if (tree[curr].size() == 1) return ans[curr] = 1;
    int sum = 0;
    for (int x : tree[curr]) {
      if (x != last) sum += dfs(x, curr);
    }
    return ans[curr] = sum;
  };
  dfs(0, 0);
  sort(ans.begin(), ans.end());
  for (int x : ans) cout << x << ' ';
  return cout << '\n', 0;
}
