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

#GL0000137. Tất cả đều bằng nhau (All are Same)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tất cả đều bằng nhau (All are Same)

All are Same

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Polycarp has an array of nn integers. He chooses a positive integer kk and may repeatedly pick an index ii and decrease aia_i by exactly kk. Each index can be picked any number of times, including zero.

Find the maximum kk for which all elements can become equal. Print -1 if valid values of kk are unbounded. Initial and final elements may be negative.

Input

The first line contains an even integer nn. The second line contains nn integers aia_i.

Output

Print the largest possible kk, or -1 if arbitrarily large values are possible.

Subtasks

  • Subtask 1 (20 points): 4≤n≤104\le n\le 10 and nn even; −50≤ai≤50-50\le a_i\le 50.
  • Subtask 2 (30 points): 4≤n≤204\le n\le 20 and nn even; −10 000≤ai≤10 000-10\,000\le a_i\le 10\,000.
  • Subtask 3 (50 points): 4≤n≤404\le n\le 40 and nn even; −1 000 000≤ai≤1 000 000-1\,000\,000\le a_i\le 1\,000\,000.

Examples

Input

6
1 5 3 1 1 5

Output

2

Explanation

The differences from the first element are 0,4,2,0,0,40,4,2,0,0,4, whose greatest common divisor is 22. Choosing k=2k=2 makes all numbers equal to 11 by decreasing each 55 twice and 33 once. No larger kk divides both 22 and 44.