#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100010];
int hijos[100010];
bool visit[100010];
void dfs(int x) {
  visit[x] = true;
  for (int i = 0; i < graph[x].size(); i++) {
    int v = graph[x][i];
    if (!visit[v]) {
      if (graph[v].size() == 1) hijos[v] = 1;
      dfs(v);
      hijos[x] += hijos[v];
    }
  }
}
vector<int> res;
int main() {
  int n, a;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> a;
    graph[i].push_back(a);
    graph[a].push_back(i);
  }
  dfs(1);
  if (n == 1)
    cout << "1";
  else {
    for (int i = 1; i <= n; i++) res.push_back(hijos[i]);
    sort(res.begin(), res.end());
    for (int i = 0; i < n; i++) cout << res[i] << " ";
  }
}
