#include <bits/stdc++.h>
using namespace std;
vector<long long int> graph[100005];
bool isVisited[200005] = {false};
vector<long long int> res;
void dfs(long long int start) {
  isVisited[start] = true;
  if (graph[start].size() == 0) {
    res[start - 1] = 1;
    return;
  }
  vector<long long int>::iterator it = graph[start].begin();
  for (it; it != graph[start].end(); it++) {
    if (!isVisited[*it]) {
      dfs(*it);
      res[start - 1] += res[(*it) - 1];
    }
  }
}
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 2; i <= n; i++) {
    long long int s;
    cin >> s;
    graph[s].push_back(i);
  }
  for (long long int i = 0; i < n; i++) {
    res.push_back(0);
  }
  dfs(1);
  sort(res.begin(), res.end());
  for (long long int i = 0; i < res.size(); i++) {
    cout << res[i] << " ";
  }
  return 0;
}
