#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
std::vector<long long int> adj[N];
std::vector<long long int> leaf(N);
bool vis[N];
void dfs(long long int u) {
  vis[u] = true;
  leaf[u] = 0;
  if (adj[u].size() == 1 && u != 1) leaf[u] = 1;
  for (auto it : adj[u]) {
    if (!vis[it]) {
      dfs(it);
      leaf[u] += leaf[it];
    }
  }
}
void solve() {
  long long int i, j, n, m, l;
  cin >> n;
  if (n == 1) {
    cout << "1" << endl;
    return;
  }
  for (i = 2; i < n + 1; i++) {
    cin >> m;
    adj[i].push_back(m);
    adj[m].push_back(i);
  }
  dfs(1);
  std::vector<long long int> ans;
  for (i = 1; i < n + 1; i++) {
    ans.push_back(leaf[i]);
  }
  sort(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t = 1, i;
  while (t--) {
    solve();
  }
  return 0;
}
