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

using System;
using System.Collections.Generic;
using static System.Console;
using static System.Linq.Enumerable;

namespace AtCoderCSharp
{
    static class Program
    {
        const long MaxValue = 1000000000;
        const int MaxPrime = 100000;

        static bool Check(int N, long[] poly, long p)
        {
            var mp = (MaxValue / p + 1) * p;
            if ((mp + poly[N]) % p != 0)
            {
                return false;
            }
            for (var i = 1L; i <= Math.Min(p - 1, N); ++i)
            {
                var v = 0L;
                for (var k = i; k <= N; k += p - 1)
                {
                    v += (mp + poly[N]);
                    v %= p;
                }
                if (v != 0)
                {
                    return false;
                }
            }
            return true;
        }

        static IEnumerable<long> Primes(int N,long val)
        {
            var sieve = new bool[MaxPrime + 1];
            for(var p = 2; p <= MaxPrime; ++p)
            {
                if (sieve[p])
                {
                    continue;
                }
                if (p <= N || val % p == 0)
                {
                    yield return p;
                    while (val % p == 0)
                    {
                        val /= p;
                    }
                }
            }
            if (val != 1)
            {
                yield return val;
            }
        }

        static void Main(string[] args)
        {
            var N = int.Parse(ReadLine());
            var poly = Range(0, N + 1).Select(v => long.Parse(ReadLine())).ToArray();
            foreach(var p in Primes(N, poly[0]).Where(p => Check(N, poly, p)))
            {
                WriteLine(p);
            }
        }
    }
}