// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
using namespace std;
// mylittledoge
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
int N;
cin >> N;
vector< vector<int> > son(N);
for(int i =1; i < N; i++) {
int a;
cin >> a;
son[--a].push_back(i);}
vector<int> S(N,1);
for(int i =N-1; i >= 0; i--)
ALL_THE(son[i],it) S[i] +=S[*it];
vector< pair<int,int> > D;
for(int i =0; i < N; i++) if(son[i].size() > 1)
D.push_back(make_pair(son[i].size(),i));
sort(D.begin(),D.end());
cout << "1";
for(int k =N-1; k >= 1; k--) if(N%k == 0) {
bool ok =true;
for(int i =D.size()-1; i >= 0; i--) if(S[D[i].ss] > k) {
int s =0;
ALL_THE(son[D[i].ss],it) s +=S[*it]%k;
if(s+1 > k) {ok =false; break;}
}
if(ok) cout << " " << N/k;}
cout << "\n";
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW0KI2luY2x1ZGUgPGNzdGRpbz4KLy8gYml0Y2ggcGxlYXNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8bGlzdD4KI2luY2x1ZGUgPGNtYXRoPgoja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