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 PyPy3 (2.4.0) (judge verdict: Runtime Error)

#とりあえずRE削除目標
from random import randint
import math
#from math import gcd
from fractions import gcd
def is_prime(x):#https://qiita.com/neko_the_shadow/items/4ebad619564a48f5a97f
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True

n = int(input())
a=[]
for _ in range(n+1):
    a.append(int(input()))
a.reverse()

prm0 = []
prm02 = []
a0 = a[0]

sq = int(a0**(1/2))+3

for i in range(2,sq):
    if a0%i==0:
        prm0.append(i)
        prm02.append(a0//i)
pr_ = prm0+prm02
if a0:
    pr_.append(a0)
pr = []
for p in pr_:
    if is_prime(p):
        pr.append(p)
def f(x,p):
    res = 0
    for i in range(n+1):
        res += pow(x,i,p)*a[i]
    return res
ans_l = []
pr2 = {p for p in pr}
ax = 0
for i in range(50):
    t = randint(5,1000)
    if f(t,p):
        ax = f(t,p)
        break
for _ in range(50):
    ans = ax
    rn = randint(1,10**9)
    ans = gcd(ans,f(rn,ax))
    for p in pr:
        if ans%p and p in pr2:
            pr2.del(p)

for p in pr2:
    print(p)