#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> graph[100 * 1000 + 1];
int dp[100 * 1000 + 1];
void dfs(int nod) {
  for (int e : graph[nod]) {
    dfs(e);
    dp[nod] += dp[e];
  }
  if (graph[nod].size() == 0) dp[nod] = 1;
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int cur;
    cin >> cur;
    cur--;
    graph[cur].push_back(i + 1);
  }
  for (int i = 0; i < n; ++i) {
    dp[i] = 0;
  }
  dfs(0);
  sort(dp, dp + n);
  for (int i = 0; i < n; ++i) {
    cout << dp[i] << " ";
  }
  cout << endl;
}
