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 Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.util.*;
import java.util.function.*;
import java.lang.*;

import java.util.*;
import java.io.*;

public class Main {
    static List<Long> primeDivisors(long X){
        List<Long> ans = new LinkedList<>();
        for(long d=2; d*d<=X; d++){
            if(X%d==0) ans.add(d);
            while(X%d==0) X /= d;
        }
        if(X>1) ans.add(X);
        return ans;
    }

    static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        LinkedList<Long> a = new LinkedList<>();
        for(int n=N; n>=0; n--){
            long e = sc.nextLong();
            if(e!=0) a.add(Math.abs(e));
        }


        long g = a.peek();
        for(long e:a) g = gcd(g,e);

        List<Long> ans = primeDivisors(g);
        for(long p:ans) System.out.println(p);


    }
}