#include <bits/stdc++.h>
using namespace std;
void TreeDFS(int v, vector<vector<int> > &adjList, vector<bool> &visited,
             vector<int> &numL) {
  visited[v] = true;
  vector<int> temp;
  for (auto z : adjList[v]) {
    if (!visited[z]) {
      visited[z] = true;
      TreeDFS(z, adjList, visited, numL);
      temp.push_back(z);
    }
  }
  if (temp.size() == 0) {
    numL[v] = 1;
    return;
  }
  for (int i = 0; i < temp.size(); ++i) {
    numL[v] += numL[temp[i]];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, p;
  cin >> n;
  vector<vector<int> > adjList(n + 1);
  for (int i = 2; i < n + 1; ++i) {
    cin >> p;
    adjList[i].push_back(p);
    adjList[p].push_back(i);
  }
  vector<bool> visited(n + 1, false);
  vector<int> ans;
  vector<int> numL(n + 1, 0);
  TreeDFS(1, adjList, visited, numL);
  sort(numL.begin(), numL.end());
  for (int i = 1; i <= n; ++i) cout << numL[i] << " ";
  cout << "\n";
  return 0;
}
