#P7191. [COCI 2007/2008 #6] GRANICA

[COCI 2007/2008 #6] GRANICA

Problem Description

Luka first wrote the numbers from nn license plates onto a piece of paper. Then, he tried to find an integer mm such that all the numbers on the paper leave the same remainder when divided by mm.

Luka wants to find as many different values of mm as possible.

Write a program that, given Luka’s nn integers, determines all such mm.

Note that you must ensure mm is a positive integer, i.e., m>1m > 1.

Input Format

The first line contains a positive integer nn, the number of integers.

In the next nn lines, each line contains an integer aia_i, representing a number on the paper, and all aia_i are guaranteed to be distinct.

The testdata guarantees that there exists at least one mm that satisfies the requirement.

Output Format

Output all values of mm that satisfy the requirement in any order on the first line.

3
6
34
38 

2 4

5
5
17
23
14
83 

3

Hint

Sample #1 Explanation

All integers leave remainder 00 when divided by 22, and remainder 22 when divided by 44.

Constraints

  • For 60%60\% of the testdata, 2n1002 \le n \le 100, 1ai1041 \le a_i \le 10^4.
  • For 100%100\% of the testdata, 2n1002 \le n \le 100, 1ai1091 \le a_i \le 10^9.

Notes

  • The full score for this problem is 5050 points.
  • This problem enables the O2 optimization switch by default.
  • Translated from COCI2007-2008 CONTEST #6 T3 GRANICA. Translator:
    https://www.luogu.com.cn/user/219791
  • Thanks to
    https://www.luogu.com.cn/user/60864
    ing the checker, which you can download from the attachments.

Translated by ChatGPT 5