PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000052. Tìm mô-đun chung từ các phần dư bằng nhau (Simple division)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tìm mô-đun chung từ các phần dư bằng nhau (Simple division)

Simple division

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Given NN integers a1,…,aNa_1,\ldots,a_N (possibly negative), find the greatest positive integer dd for which every aia_i has the same Euclidean remainder modulo dd. If all values are equal, output 0 by convention.

Input

The first line contains NN; the next contains exactly NN integers.

Output

Print the largest positive modulus, or 0 by convention.

Subtasks

  • Subtask 1 (20 points): 2≤N≤82 \le N \le 8; −100≤ai≤100-100 \le a_i \le 100 (Phuoc Hung OJ version bound)
  • Subtask 2 (30 points): 2≤N≤1002 \le N \le 100; −104≤ai≤104-10^{4} \le a_i \le 10^{4} (Phuoc Hung OJ version bound)
  • Subtask 3 (50 points): 2≤N≤10002 \le N \le 1000; −109≤ai≤109-10^{9} \le a_i \le 10^{9} (Phuoc Hung OJ version bound)

Examples

Input

4
7 13 19 25

Output

6

Explanation

All four numbers have remainder 11 modulo 66. Their differences from 77 are 6,12,186,12,18, whose GCD is 66.