#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-9;
pair<int, int> operator+(const pair<int, int>& p1, const pair<int, int>& p2) {
  return pair<int, int>(p1.first + p2.first, p1.second + p2.second);
}
pair<int, int> operator-(const pair<int, int>& p1, const pair<int, int>& p2) {
  return pair<int, int>(p1.first - p2.first, p1.second - p2.second);
}
int operator*(const pair<int, int>& p1, const pair<int, int>& p2) {
  return (p1.first * p2.first + p1.second * p2.second);
}
int operator^(const pair<int, int>& p1, const pair<int, int>& p2) {
  return (p1.first * p2.second - p1.second * p2.first);
}
int n;
vector<int> v[100005];
int happy[100005];
void build() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    ;
    v[x].push_back(i);
  }
}
void init() {}
void dfs(int idx) {
  int deg = v[idx].size();
  if (!deg) {
    happy[idx] = 1;
    return;
  }
  for (auto x : v[idx]) {
    dfs(x);
    happy[idx] += happy[x];
  }
}
void solve() {
  dfs(1);
  sort(happy + 1, happy + n + 1);
  for (int i = 1; i <= n; i++) {
    printf("%d ", happy[i]);
  }
}
int main() {
  int _t = 1;
  build();
  while (_t--) {
    init();
    solve();
  }
  return 0;
}
