#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj(100005);
vector<int> cnt_roots(100005, 0);
vector<int> root_map(100005, 0);
vector<int> vis(100005, 0);
void dfs(int node, int parent) {
  vis[node] = 1;
  int ans = 0;
  for (int i = 0; i < adj[node].size(); i++) {
    int child = adj[node][i];
    if (child != parent && vis[child] == 0) {
      dfs(child, node);
      ans = ans + cnt_roots[child];
    }
  }
  if (adj[node].size() == 1 && node != 1) {
    ans = 1;
  }
  root_map[ans]++;
  cnt_roots[node] = ans;
}
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    adj[i].push_back(x);
    adj[x].push_back(i);
  }
  dfs(1, 0);
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < root_map[i]; j++) {
      if (root_map[i] > 0) cout << i << " ";
    }
  }
  return 0;
}
