Same Remainder Divisors

Interview

Time limit1sMemory limit128 MB

Summary
Given N distinct integers, find all M greater than 1 for which all numbers share the same remainder mod M, output divisors of pairwise differences in increasing order.
Level

Medium4 of 10

Topics
Number theory, Math, Brute force
Solved
No attempts yet

Problem

You are given N distinct positive integers. Find every integer M greater than 1 such that all of the given numbers leave the same remainder when divided by M.

Input

The first line contains N, the number of integers written down. (2 <= N <= 100)

Each of the next N lines contains one integer. Every integer is at least 1 and at most 1,000,000,000, and no integer appears more than once.

The input is always chosen so that at least one valid M exists.

Output

Print all possible values of M on one line, separated by spaces. The values must be printed in increasing order.

Examples2

  1. Example 1

    Input
    3
    6
    34
    38
    
    Expected output
    2 4
    
  2. Example 2

    Input
    5
    5
    17
    23
    14
    83
    
    Expected output
    3