#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
long long power(long long b, long long e, long long m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
vector<vector<long long int>> adj;
vector<bool> visited;
vector<long long int> leaf;
vector<long long int> ans;
long long int n;
void DFS(long long int x) {
  visited[x] = true;
  if (adj[x].size() == 1 && x != 1) leaf[x] = 1;
  for (long long int i = 0; i < adj[x].size(); i++) {
    if (!visited[adj[x][i]]) {
      DFS(adj[x][i]);
      leaf[x] += leaf[adj[x][i]];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  long long int a;
  adj.resize(n + 1);
  visited.resize(n + 1);
  leaf.resize(n + 1);
  leaf[0] = 0;
  for (long long int i = 1; i < n; i++) {
    cin >> a;
    adj[i + 1].push_back(a);
    adj[a].push_back(i + 1);
  }
  if (n == 1) {
    cout << 1;
    return 0;
  }
  DFS(1);
  sort(leaf.begin(), leaf.end());
  for (long long int i = 1; i <= n; i++) cout << leaf[i] << " ";
  return 0;
}
