#include <bits/stdc++.h>
using namespace std;
class Timer {
  clock_t start;
  string name;

 public:
  Timer() {
    name = "";
    start = clock();
  }
  Timer(string s) {
    name = s;
    start = clock();
  }
  ~Timer() {
    fprintf(stderr, "%s: %.3gs\n", name.c_str(),
            1.0 * (clock() - start) / CLOCKS_PER_SEC);
  }
};
const double EPS = 1e-9;
const long double PI = acos(-1.0L);
template <typename dtype>
inline dtype sq(dtype a) {
  return a * a;
}
template <typename dtype1, typename dtype2>
inline pair<dtype1, dtype2> mp(dtype1 a, dtype2 b) {
  return make_pair(a, b);
}
template <typename dtype1, typename dtype2>
inline dtype1 safeMod(dtype1 a, dtype2 m) {
  return (a % m + m) % m;
}
template <typename dtype1, typename dtype2>
inline bool isEq(dtype1 a, dtype2 b) {
  return abs(a - b) < EPS;
}
template <typename dtype1, typename dtype2, typename dtype3>
inline bool isEq(dtype1 a, dtype2 b, dtype3 eps) {
  return abs(a - b) < eps;
}
template <typename dtype>
inline dtype toRad(dtype deg) {
  return deg * PI / 180.0;
}
template <typename dtype>
inline dtype toDeg(dtype rad) {
  return rad * 180.0 / PI;
}
template <typename dtype>
inline bool isKthBitOn(dtype n, int k) {
  assert(n <= numeric_limits<dtype>::max());
  assert(k <= numeric_limits<dtype>::digits);
  dtype ONE = 1;
  return bool((n & (ONE << k)));
}
template <typename dtype>
inline void setKthBit(dtype& n, int k) {
  assert(n <= numeric_limits<dtype>::max());
  assert(k <= numeric_limits<dtype>::digits);
  dtype ONE = 1;
  n = (n | (ONE << k));
}
const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;
vector<int> tree[MAX];
int sublef[MAX];
priority_queue<int, vector<int>, greater<int>> pq;
void dfs(int u) {
  bool isLeaf = true;
  for (int v : tree[u]) {
    isLeaf = false;
    dfs(v);
    sublef[u] += sublef[v];
  }
  if (isLeaf) sublef[u] = 1;
  pq.push(sublef[u]);
}
int ans[MAX];
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 2, p; i <= n; i++) {
    cin >> p;
    tree[p].push_back(i);
  }
  dfs(1);
  int k = 0;
  while (!pq.empty()) {
    int c = 1;
    int cur = pq.top();
    pq.pop();
    while (!pq.empty() && pq.top() == cur) {
      c++;
      pq.pop();
    }
    for (int i = k + 1; i <= k + c; i++) ans[i] = cur;
    k += c;
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
