#include <bits/stdc++.h>
using namespace std;
bool checkbitt(long long int num, int pos);
long long int setbitt(long long int num, long long int pos);
long long int resetbitt(long long int num, int pos);
map<int, vector<int> > graph;
int leaf[1000000];
vector<int> gain;
void dfs(int u) {
  leaf[u] = graph[u].empty();
  for (auto x : graph[u]) {
    dfs(x);
    leaf[u] += leaf[x];
  }
  gain.push_back(leaf[u]);
}
int solve() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    graph[x].push_back(i);
  }
  dfs(1);
  sort(gain.begin(), gain.end());
  for (auto x : gain) cout << x << " ";
  return 0;
}
int main() {
  int cs = 1;
  int cn = 1;
  while (cs--) {
    solve();
  }
}
bool checkbitt(long long int num, int pos) { return (num >> pos) & 1; }
long long int setbitt(long long int num, long long int pos) {
  return (1 << pos) | num;
}
long long int resetbitt(long long int num, int pos) {
  if (!checkbitt(num, pos))
    return num;
  else
    return (1 << pos) ^ num;
}
