#d1402. 最大公约数

最大公约数

Greatest Common Divisor

Problem Description

You have a ring with nn positive integers on it. You may cut the ring into kk segments, each containing one or more numbers.

For a cutting scheme, its "beauty" is defined as the greatest common divisor of the sums of the numbers in each segment. You want to maximize the beauty of the cutting scheme. For k=1,2,…,nk = 1, 2, \dots, n, output the answer.

Input Format

The first line contains an integer nn, the number of numbers on the ring.

The next line contains nn positive integers; the ii-th number aia_i is the ii-th number on the ring.

Output Format

Output nn lines; the ii-th line is the maximum beauty when cut into ii segments.

Sample Input

7
2 3 3 3 3 3 3

Sample Output

20
5
2
2
1
1
1

Constraints

There are 10 test cases in total.

Test cases 1,21, 2 satisfy n≤20n \le 20.

Test cases 3,4,53, 4, 5 satisfy ai≤5a_i \le 5.

For all data: 1≤n≤20001 \le n \le 2000, 1≤ai≤5×1071 \le a_i \le 5 \times 10^7.

Hint

See the attached file.