#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> g[N];
int sz[N];
void dfs(int u, int par);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 2; i <= n; ++i) {
    int p;
    cin >> p;
    g[p].push_back(i);
    g[i].push_back(p);
  }
  dfs(1, 0);
  sort(sz + 1, sz + 1 + n);
  for (int i = 1; i <= n; ++i) {
    cout << sz[i] << ' ';
  }
}
void dfs(int u, int par) {
  sz[u] = 0;
  for (auto &v : g[u]) {
    if (v != par) {
      dfs(v, u);
      sz[u] += sz[v];
    }
  }
  if (sz[u] == 0) {
    sz[u] = 1;
  }
}
