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 Ruby (2.3.3) (judge verdict: Time Limit Exceeded)

def eratosthenes(n)
    l=[1]*n;r=[]
    (2..n).each{|i|
        if l[i-1]!=0
            r+=[i];j=2
            while i*j<=n
                l[i*j-1]=0;j+=1
            end
        end
    }
    return r
end
Ps=eratosthenes(40000)
def divisor(n)
    Ps.each{|q|
        if q*q>n then return -1 end
        if n%q==0 then return q end
    }
end
def prime_division(n)
    d={}
    d.default=0
    while n>1
        q=divisor(n)
        if q==-1 then d[n]+=1;break
        else d[q]+=1;n/=q end
    end
    return d
end


require 'prime'
N=gets.to_i
A=(N+1).times.map{gets.to_i}
G=(prime_division(A.inject(A[0],:gcd)).map{|k,_|k}+eratosthenes(N)).sort.uniq
def div(q)
    if A[-1]%q!=0 then return A[-1]%q end
    if A.inject(0){|m,a|m+a%q}==0 then return 0 end
    l=A[q,N+1-q].map{|a|a%q}
    r=A[0,q].map{|a|a%q}
    #p l,r
    ind=0
    (0..(N-q)).each{|i|
        a=r[ind];ind+=1
        r[-1] = (r[-1]+a)%q
        r << l[i]
        #p r
    }
    r[-q,q].inject :+
end
G.each{|q|
    #p q
    if div(q)==0 then p q end
}