#include <bits/stdc++.h>
using namespace std;
vector<int> e[101000];
int f[101000], n;
int dfs(int u) {
  if (e[u].size() == 0) return 1;
  int ans = 0;
  for (int i = 0; i < e[u].size(); i++) {
    ans += dfs(e[u][i]);
  }
  f[u] = ans;
  return ans;
}
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int u;
    scanf("%d", &u);
    e[u].push_back(i);
  }
  dfs(1);
  sort(f + 1, f + n + 1);
  for (int i = 1; i <= n; i++) {
    printf("%d ", max(1, f[i]));
  }
}
