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.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    const int MOD = 998244353;

    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        DateTime start = DateTime.Now;
        HashSet<long> candidate = new HashSet<long>();
        var a = Enumerable.Repeat(0, n + 1).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        var oddsum = a.Where((_, x) => x % 2 == 1).Sum();
        var evensum = a.Where((_, x) => x % 2 == 0).Sum();
        var res = Factors(a.Last()).Validate(Abs(oddsum + evensum)).Validate(Abs(oddsum - evensum));
        Console.WriteLine(string.Join("\n", res.OrderBy(x => x)));
    }

    static IEnumerable<long> Validate(this IEnumerable<long> seq, long sum)
    {
        foreach (var item in seq) if(sum % item == 0) yield return item;
    }

    static IEnumerable<long> Factors(long n)
    {
        if (n % 2 == 0) yield return 2;
        while (n % 2 == 0) n /= 2;
        long i = 3;
        while (i * i <= n)
        {
            if (n % i == 0) yield return i;
            while (n % i == 0) n /= i;
            i += 2;
        }
        if (n != 1) yield return n;
    }

}