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 9.2.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

inline int F(poly f,int x,int p){
	int ret=0,now=1;
	for (auto i:f) ret=(ret+1ll*now*(i%p+p))%p,now=1ll*now*x%p;
	return ret;
}

int main(){
	srand(time(0));
	int n=read()+1;
	poly a(n);
	Dow(i,n-1,0) a[i]=read();
	poly b;
	int x=abs(a[0]);
	if (x==0){
		for (auto i:a) x+=i;
		x=abs(x);
	}
	for (int i=2;i*i<=x;i++){
		if (x%i==0) b.pb(i),x/=i;
	}
	if (x!=1) b.pb(x);
	poly ans;
	for (auto i:b){
		if (i<=2*n){
			bool flag=1;
			FOR(j,0,i) if (F(a,j,i)){
				flag=0;break;
			}
			if (flag) ans.pb(i);
		} else {
			bool flag=1;
			FOR(j,0,20){
				int x=(rand()<<16^rand())%i;
				if (F(a,x,i)){
					flag=0;break;
				}
			}
			if (flag) ans.pb(i);
		}
	}
	for (auto i:ans) printf("%d\n",i);
}