#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100007];
bool IsLeaf[100007], vis[100007];
vector<pair<int, int> > V(100007);
pair<int, int> dfs(int root) {
  if (vis[root]) return {0, 0};
  vis[root] = 1;
  int cnt = 0, leaf = 0;
  if (IsLeaf[root] & root != 1) leaf++;
  for (auto x : graph[root]) {
    if (vis[x] == 0) {
      pair<int, int> a = dfs(x);
      cnt += a.second;
      leaf += a.first;
    }
  }
  V[root] = {leaf, cnt + 1};
  return {leaf, cnt + 1};
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  for (int i = 1; i <= n - 1; i++) {
    int v;
    cin >> v;
    graph[i + 1].push_back(v);
    graph[v].push_back(i + 1);
  }
  int leaf = 0;
  for (int i = 1; i <= n; i++) {
    if (graph[i].size() == 1) {
      leaf++;
      IsLeaf[i] = 1;
    }
  }
  dfs(1);
  vector<pair<int, int> > Ar;
  for (int i = 1; i <= n; i++) {
    Ar.push_back(V[i]);
  }
  sort(Ar.begin(), Ar.end());
  for (int i = 1; i <= n; i++) cout << Ar[i - 1].first << " ";
  return 0;
}
