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 C (GCC 5.4.1) (judge verdict: Runtime Error)

#include<stdio.h>
#define N 10001
#define P 1<<20
typedef long long Int;
Int get_primes(Int primes[P]){
    Int i,j,n=0,flag[P];
    for(i=0;i<P/2;i++) flag[i*2+1] = 1;
    for(i=0;i<P/2;i++) flag[i*2] = 0;
    flag[0] = flag[1] = 0; flag[2] = 1; primes[n++] = 2;
    for(i=3;i<P;i++) if(flag[i]) {
        for(j=2;j<=(P-1)/i;j++) flag[i*j] = 0;
        primes[n++] = i;
    }
    return n;
}
Int pf_decompose(Int num,Int primes[P],Int prime_factor[P],Int n){
    Int i,num_pf;
    for(i=num_pf=0;i<n&&primes[i]*primes[i]<=num;i++){
        if(num%(primes[i])==0) prime_factor[num_pf++] = primes[i];
        while(num%(primes[i])==0) num/=primes[i];
    }
    if(num!=1) prime_factor[num_pf++] = num;
    return num_pf;
}
int main(void){
    Int i,j,k,n,np,npf,total,tmp,poly[N],primes[P],pf[P];
    np = get_primes(primes);
    scanf("%lld",&n);
    for(i=n;i>=0;i--) scanf("%lld",&poly[i]);
    npf = pf_decompose(poly[0],primes,pf,np);
    for(i=0;i<npf;i++){
        for(j=1;j<=n;j++){/* 0 is ok */
            for(total=0,tmp=1,k=0;k<=n;tmp=(tmp*j)%pf[i],k++) total = (total+poly[k]*tmp)%pf[i];
            if(total%pf[i]!=0) break;
        }
        if(j>n) printf("%lld\n",pf[i]);
    }
    return 0;
}