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>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> prime, sieve(31622, 1);
    for(unsigned long i = 2; i < 31622; ++i){
        if(sieve[i]){
            prime.push_back(i);
            for(auto j = i * i; j <= 31622; j += i)sieve[j] = 0;
        }
    }
    vector<long> a(N + 1);
    for(auto& i : a)cin >> i;

    random_device rdv;
    mt19937 mt(rdv());
    uniform_int_distribution<long> uid(0, N * N);
    long u{a.back()};
    for(unsigned long i = 0; i < 3000; ++i){
        long k{0}, x{uid(mt)};
        for(const auto j : a)((k *= x) += j) %= u;
        u = __gcd(u, k);
    }
    vector<unsigned long> ans;
    for(const auto i : prime){
        if(u % i == 0){
            ans.push_back(i);
            while(u % i == 0)u /= i;
        }
    }
    for(const auto i : ans)cout << i << endl;
}