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: Accepted)

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=1e4+5;
bool v[N];
int a[N],b[N],n,g;

bool check(int p){
	if(a[0]%p) return 0;
	for(int i=0;i<p-1;i++) b[i]=0;
	for(int i=0;i<=n;i++) b[i%(p-1)]=(b[i%(p-1)]+a[i])%p;
	for(int i=0;i<p-1;i++) if(b[i]) return 0;
	return 1;
}

signed main(){
	read(n);
	for(int i=n;~i;i--) read(a[i]),g=__gcd(g,abs(a[i]));
	for(int i=2;i<=n;i++) if(!v[i]){
		if(check(i)) write(i),puts("");
		for(int j=i+i;j<=n;j+=i) v[j]=1;
	}
	for(int i=2;i*i<=g;i++) if(g%i==0){
		while(g%i==0) g/=i;
		if(i>n) write(i),puts("");
	}
	if(g>n) write(g);
}