Under construction

Still being built. Things may change

Ordered Problem Set

Interview

Time limit1sMemory limit2048 MB

Summary
Given n distinct difficulties in contest order, list each divisor k greater than 1 of n where every block of n/k consecutive problems is easier than the next block.
Level

Easy2 of 10

Topics
Implementation, Brute force, Array
Solved
No attempts yet

Problem

You are running a programming contest with nn problems of distinct difficulties. You wish to announce ahead of time that the problems are ordered so that, when they 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, the problems have already been sent to the printer, so the order cannot be changed. For what values of kk would this claim be true?

Input

The first line contains a single integer nn (2≤n≤502 \le n \le 50), the number of problems. Each of the next nn lines contains a single integer dd (1≤d≤n1 \le d \le n), the difficulty of a problem, listed in the order the problems appear in the set. The difficulties are distinct. Difficulty 11 is the easiest and difficulty nn is the hardest.

Output

Output a list of integers, one per line, containing all valid values of kk in increasing order. If no valid value exists, output −1-1.

Examples3

  1. Example 1

    Input
    6
    1
    3
    2
    4
    5
    6
    
    Expected output
    2
    
  2. Example 2

    Input
    6
    1
    2
    3
    4
    5
    6
    
    Expected output
    2
    3
    6
    
  3. Example 3

    Input
    6
    6
    5
    4
    3
    2
    1
    
    Expected output
    -1