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# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Linq;

namespace CompetitiveProgCsLib
{
	public static class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;
		static T MIN<T>(params T[] args) => args.Min();
		static T MAX<T>(params T[] args) => args.Max();
		
		public static void Main(string[] args)
		{
			var li = new List<int>();
			var n = RI + 1;
			for(int i = 0;i < n;i++)
			{
				var a = RI;
				li.Add(a);
			}
			var ps = tf(li.Last());
			li.RemoveAt(li.Count - 1);
			li.Reverse();
			foreach(var p in ps)
			{
				if(li.All(x => x % p == 0))
				{
					Out(p);
					continue;
				}
				bool flg = false;
				for (int i = 1; i < p; i++)
				{
					var ret = poly_calc(li, i, p);
					if (ret != 0)
					{
						flg = true;
						break;
					}
				}
				if (!flg) Out(p);
			}
		}

		public static List<int> tf(int n)
		{
			var li = new List<int>();
			var nn = (int)Math.Sqrt(n);
			if (n % 2 == 0)
			{
				li.Add(2);
				li.Add(n / 2);

			}
			for (int i = 3;i <= nn;i += 2)
			{
				if (n % i == 0)
				{
					li.Add(i);
					li.Add(n / i);
				}
			}
			if (li.Count == 0) li.Add(n);
			li.Sort();
			return li;
		}

		public static int poly_calc(List<int> poly, int x, int mod)
		{
			long result = 0;
			long X = x;
			for (int i = 0;i < poly.Count;i++)
			{
				result = (result + poly[i] * X) % mod;
				X = (X * x) % mod;
			}
			return (int)result;
		}
	}
}