시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 256 MB 8 2 2 25.000%

문제

Byteasar has discovered a cave. It appears that the cave contains n chambers connected with passages in such a way that there exists a single way of getting from any chamber to any other chamber.

The cave should now be examined more thoroughly, so Byteasar has asked his friends for help. They have all arrived at the cave and they are willing to divide themselves into groups. Each group should examine the same number of chambers, and each chamber should be examined by exactly one group. Additionally, for the groups not to interfere with each others’ work, the members of each group should be able to move between the assigned chambers without passing through chambers assigned to other groups.

How many groups can the explorers be divided into?

입력

The first line of the input contains one integer n (2 ≤ n ≤ 3 000 000) denoting the number of chambers in the cave. The chambers are numbered 1 through n.

The following n − 1 lines describe connections between the chambers. The i-th of these lines contains an integer ai (1 ≤ ai ≤ i) which represents a passage connecting chambers number i + 1 and ai.

출력

Your program should output a single line containing all integers k, such that the chambers can be divided into k disjoint sets of equal size, and one can move between any two chambers belonging to the same set passing only through chambers from this set. The numbers should be written in an ascending order and separated with single spaces.

예제 입력 1

6
1
2
3
3
5

예제 출력 1

1 3 6

힌트