#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int K = (1 << 17) + 10;
const long long int INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;
vector<int> V[N];
int sz[N];
int ans[N];
void dfs(int node, int p) {
  bool isLeaf = true;
  for (auto v : V[node]) {
    if (v != p) {
      isLeaf = false;
      dfs(v, node);
      sz[node] += sz[v];
    }
  }
  sz[node] += isLeaf;
}
int main(int argc, char const *argv[]) {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    V[i].push_back(x);
    V[x].push_back(i);
  }
  dfs(1, -1);
  vector<int> X;
  for (int i = 1; i <= n; i++) {
    X.push_back(sz[i]);
  }
  sort((X).begin(), (X).end());
  for (int i = 1; i <= n; i++) {
    ans[i] = X[i - 1];
  }
  for (int ii = 1; ii < n + 1; ii++) cout << ans[ii] << " ";
  cout << "\n";
  return 0;
}
