#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
const int N = 1e5 + 7;
int n, dp[N];
vector<int> G[N];
int dfs(int v) {
  int cnt = 0;
  for (auto u : G[v]) {
    cnt += dfs(u);
  }
  if (cnt == 0) cnt++;
  return dp[v] = cnt;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int p;
    cin >> p;
    G[p].push_back(i);
  }
  dfs(1);
  sort(dp + 1, dp + n + 1);
  for (int i = 1; i <= n; i++) cout << dp[i] << " ";
  return 0;
}
