#P1154. 奶牛分厩

奶牛分厩

Description

Farmer John has N(1N5000)N(1 \le N \le 5000) cows. Each cow has a unique ID sis_i, different from every other cow. All the cows sleep in a barn that has KK stalls, labeled 00 to K1K-1. No two cows may share the same stall. Each cow knows which stall to sleep in because John taught them division: the stall index for the ii-th cow is SimodKS_i \bmod K.

Find the smallest KK such that the assignment is valid (i.e., all cows are assigned to distinct stalls).

Input Format

The first line contains a positive integer NN. Lines 22 through N+1N+1 each contain one integer, the ID of a cow.

Output Format

Output a single integer, the minimal KK. For all testdata, such a KK is guaranteed to exist.

5 
4 
6 
9 
10 
13 

8

Hint

Si(1Si1000000)S_i(1\le S_i \le 1000000)

Translated by ChatGPT 5