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

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 10010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
mt19937 rnd(time(0));
int n,a[N];
int calc(int x,int p)
{
	int s=(a[n]%p+p)%p;
	for (int i=n-1;i>=0;i--)
	s=(1ll*s*x+a[i]%p+p)%p;
	return s;
}
void check(int x)
{
	if (x<=2000)
	{
		for (int i=0;i<x;i++) if (calc(i,x)) return;
	}
	else assert(0);
	for (int i=1;i<=2000;i++)
	{
		int u=rnd();
		if (u<0) u=-u;u%=x;
		if (calc(u,x)) return;
	}
	cout<<x<<endl;
}
signed main()
{
	n=read();
	for (int i=n;i>=0;i--) a[i]=read();
	int x=abs(a[0]);
	for (int i=2;i*i<=x;i++)
	if (x%i==0)
	{
		while (x%i==0) x/=i;
		check(i);
	}
	if (x>1) check(x);
	return 0;
	//NOTICE LONG LONG!!!!!
}