CAVE2 - Cave

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?

Input

The first line of the input contains one integer n (2 ≤ n ≤ 3000000) 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.

Output

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.

Example

Input:
6
1
2
3
3
5

Output:
1 3 6

Task author: Jakub Lacki


Added by:acheron
Date:2013-09-08
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:AMPPZ 2011

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.