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

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
long long tmp[10100];
int main() {
	int n;
	cin >> n;
	long long hoget = 0;
	vector<long long> inputs;
	n++;
	REP(q, n) {
		int hoge;
		cin >> hoge;
		inputs.push_back(hoge);
		hoget = gcd(abs(hoge), hoget);
	}
	reverse(inputs.begin(), inputs.end());
	set<long long> kouho;
	REP(i, 30000) {
		kouho.insert(i + 2);
	}
	for (int i = 1; i <= sqrt(hoget); ++i) {
		if (hoget % i == 0) {
			kouho.insert(i);
			if (i * i != hoget) kouho.insert(hoget / i);
		}
	}
	for(auto i = kouho.begin();i != kouho.end();++i){
		int now = *i;
		if (now == 1) continue;
		int ok = 1;
		for (int i = 2; i <= sqrt(now); ++i) {
			if (now % i == 0) {
				ok = 0;
				break;
			}
		}
		if (ok == 0) continue;
		if (inputs[0] % now != 0) continue;
		REP(q, 10100) {
			tmp[q] = 0;
		}
		REP(q, n) {
			tmp[q % (now - 1)] += inputs[q];
		}
		REP(q, n) {
			if (tmp[q % (now - 1)] % now != 0) {
				ok = 0;
				break;
			}
		}
		if (ok == 1) {
			cout << now << endl;
		}
	}
}