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: Wrong Answer)

#include <bits/stdc++.h>

std::vector<long long> a;
int N;

bool condition(long long);

int main()
{
	scanf("%d", &N);
	a.resize(N + 1);
	for (int i{N}; i >= 0; i--)
		scanf("%lld", &a[i]);
	std::vector<long long> candidate;
	long long a0{std::abs(a[0])};
	for (long long i{2}; i * i <= a0; i++)
	{
		if (a0 % i) continue;
		candidate.push_back(i);
		while (a0 % i == 0) a0 /= i;
	}
	if (a0 > 1) candidate.push_back(a0);
	for (auto& e: candidate)
		printf("%lld\n", e);
	for (auto& e: candidate)
		if (condition(e))
			printf("%lld\n", e);

	return 0;
}

bool condition(long long mod)
{
	for (long long i{1}; i * i <= mod; i++)
	{
		long long pow{1}, sum{};
		for (int j{}; j <= N; j++)
		{
			sum = (sum + pow * a[j] % mod) % mod;
			pow = pow * i % mod;
		}
		if (sum) return false;
	}
	return true;
}