Ordered Problem Set

시간 제한1초메모리 제한2048 MB

요약
문제 난이도 순열이 주어질 때, n을 k로 나눈 각 구간이 다음 구간보다 모두 쉬운 조건을 만족하는 k>1의 약수를 모두 구한다.
난이도

쉬움10점 중 3점

유형
배열, 정렬, 구현
정답자
아직 제출이 없습니다

문제

You are running a programming contest that features nn problems of distinct difficulties. You wish to announce ahead of time that the problems are ordered in such a way that, if the problems are divided into kk sections numbered 11 through kk, each with exactly nk\frac{n}{k} problems, and problem pp is assigned to section ⌈kpn⌉\left \lceil \frac{kp}{n} \right \rceil, then for every pair of sections ii and jj with i<ji < j, every problem in section ii is easier than every problem in section jj. Note that kk must be greater than 11 and be a factor of nn.

However, you have just sent your problems to the printer so the order cannot be changed. For what values of kk would this claim be true?

입력

The first line of input contains a single integer nn (2≤n≤502 \le n \le 50), which is the number of problems.

Each of the next nn lines contains a single integer dd (1≤d≤n1 \le d \le n). These are the difficulties for the problems in the order that they appear in the problem set. The difficulties are distinct. The problem with difficulty 11 is the easiest problem and the problem with difficulty nn is the hardest problem.

출력

Output a list of integers, one per line. The integers are all valid values of kk in increasing order. If no such values exist, output −1-1.

예제3

  1. 예제 1

    입력
    6
    1
    3
    2
    4
    5
    6
    
    예상 출력
    2
    
  2. 예제 2

    입력
    6
    1
    2
    3
    4
    5
    6
    
    예상 출력
    2
    3
    6
    
  3. 예제 3

    입력
    6
    6
    5
    4
    3
    2
    1
    
    예상 출력
    -1