#include <bits/stdc++.h>
using namespace std;
vector<long long> v[100010];
long long arr[1000000];
long long dfs(long long u, long long par) {
  long long ans = 0;
  long long mark = 1;
  for (long long i = 0; i < v[u].size(); i++) {
    long long s = v[u][i];
    if (s == par) continue;
    mark = 0;
    ans += dfs(s, u);
  }
  return arr[u] = ans + mark;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  long long total, val;
  cin >> total;
  for (long long i = 2; i <= total; i++) {
    cin >> val;
    v[i].push_back(val);
    v[val].push_back(i);
  }
  dfs(1, -1);
  sort(arr + 1, arr + total + 1);
  for (long long i = 1; i <= total; i++) {
    cout << arr[i] << " ";
  }
}
