Under construction

Still being built. Things may change

Cows in Bed

Interview

Time limit1sMemory limit1024 MB

Summary
Find the smallest K such that the N brand numbers all have distinct remainders when divided by K.
Level

Easy3 of 10

Topics
Brute force, Hash map
Solved
No attempts yet

Problem

FJ has NN cows (1≤N≤50001 \le N \le 5000) who sleep in a barn with KK stalls numbered 00 to K−1K-1. The ii-th cow has a unique brand number SiS_i (1≤Si≤1,000,0001 \le S_i \le 1{,}000{,}000). Cow ii sleeps in stall Si mod KS_i \bmod K. Cows never share a stall.

Given the cows and their brands, find the minimum KK such that no two cows sleep in the same stall.

Input

The first line contains one integer NN. Each of the next NN lines contains one cow's brand number.

Output

Print a single line containing the minimum value of KK.

Examples1

  1. Example 1

    Input
    5
    4
    6
    9
    10
    13
    
    Expected output
    8