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)

#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/

int gcd(int x, int y) {
	if (x < y)std::swap(x, y);
	if (x % y == 0)return y;
	return gcd(y, x % y);
}

void output(int n, int m) {
	int nOut = 0;
	for (int i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			if (i > m) {
				++nOut;
				cout << i << endl;
				output(n / i, i);
			}
			else {
				output(n / i, m);
			}
		}
	}
	if (nOut == 0 && n != 1) {
		cout << n << endl;
	}
}

void proc() {
	LOAD(int, N);
	LOADVEC(int, a, N + 1);
	int res = a[N];
	for (int x = 1; x <= N; ++x) {
		int sum = 0;
		int mul = 1;
		for (int j = 0; j <= N; ++j) {
			sum += mul * a[N - j];
			mul *= x;
			sum %= res;
		}
		if (sum != 0) {
			res = gcd(std::abs(sum), res);
		}
		if (res == 1)break;
	}
	output(res, 1);
}


#endif