Problem:
Score : 800 points

Problem Statement

You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.

Constraints

0 \leq N \leq 10^4

|a_i| \leq 10^9(0\leq i\leq N)

a_N \neq 0

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
a_N
:
a_0

Output

Print all prime numbers p that divide f(x) for every integer x, in ascending order.

Sample Input 1

2
7
-7
14

Sample Output 1

2
7

2 and 7 divide, for example, f(1)=14 and f(2)=28.

Sample Input 2

3
1
4
1
5

Sample Output 2

There may be no integers that satisfy the condition.

Sample Input 3

0
998244353

Sample Output 3

998244353

Solution in Python (3.4.3) (judge verdict: Runtime Error)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def main():
    
    n=int(input())
    list=[]
    for i in range(n+1):
        list.append(int(input()))
    #print(list)
    yakusu=make_divisors(abs(list[-1]))
    #print(yakusu)
    ok=[]
    
    for yk in yakusu:
        amari=0
        #print(yk)
        for l in range(len(list)):
            now=list[l]*(yk**(n-l))
            #print(now, n-l)
            amari=((amari+now)%yk)
            #print("a:", amari)
        if amari==0:
            #print("OK:", yk)
            ok.append(yk)
    
    ok=sorted(ok, reverse=True)
    if ok[-1]==1:
        ok=ok[:-1]
    #print(ok)
    ok2=[]
    for x in range(len(ok)):
        swit=0
        for y in range(len(ok)-x-1):
            if ok[x]%ok[x+y+1]==0:
                swit=1
        if swit==0:
            ok2.append(ok[x])
    ok2=sorted(ok2)
    for x in ok2:
        print(x)
    
main()