#include <bits/stdc++.h>
using namespace std;
long long qpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) {
      res = (res * a) % 998244353;
      n--;
    } else {
      n = n / 2;
      a = (a * a) % 998244353;
    }
  }
  return res;
}
int dfs(vector<vector<int>> &list, vector<int> &vis, int node,
        vector<int> &leaf) {
  int n = list.size() - 1;
  vis[node] = 1;
  int sz = 0;
  bool ok = true;
  for (int j = 0; j < list[node].size(); j++) {
    if (vis[list[node][j]] == 0) {
      ok = false;
      sz += dfs(list, vis, list[node][j], leaf);
    }
  }
  if (ok) return leaf[node] = 1;
  return leaf[node] = sz;
}
void solve() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<vector<int>> list(n + 1);
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    list[x].push_back(i);
    list[i].push_back(x);
  }
  vector<int> leaf(n + 1), vis(n + 1);
  dfs(list, vis, 1, leaf);
  sort(leaf.begin() + 1, leaf.end());
  for (int i = 1; i <= n; i++) cout << leaf[i] << " ";
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
