#include <bits/stdc++.h>
using namespace std;
int n, l[100005], r[100005], t, c[100005], ptr, ans[100005];
vector<int> v[100005];
void dfs(int x, int y) {
  l[x] = t;
  if (v[x].size() == 0) t++;
  for (int i = (0); i < (v[x].size()); i++) dfs(v[x][i], x);
  r[x] = t;
  c[r[x] - l[x]]++;
}
int main() {
  scanf("%d", &n);
  for (int i = (2); i <= (n); i++) {
    int x;
    scanf("%d", &x);
    v[x].push_back(i);
  }
  dfs(1, 0);
  for (int i = (1); i <= (t); i++) {
    for (int j = (ptr + 1); j <= (ptr + c[i]); j++) ans[j] = i;
    ptr += c[i];
  }
  for (int i = (1); i <= (n); i++) printf("%d%c", ans[i], i == n ? '\n' : ' ');
}
