5305: H-Hash Function

内存限制:256 MB 时间限制:10.000 S
评测方式:文本比较 命题人:
提交:13 解决:5

题目描述

For a given setS={a0,a1,a2,...,an−1}, we called a hash function fS(x)perfect hash function of S, if it satisfies∀0≤i<j<n,fS(ai)≠fS(aj).

Given a set S with non-negative integers, please find the minimumpositive integer seed that function hseed(x)=x mod seed is a perfect hash function of S.

输入

The first line of input contains one integer n, describing the size of set S.

The second line contains n(1≤n≤500000)integers a0,...,an−1, describing the elements in S.

It is guaranteed that∀0≤i<j<n,ai≠aj,0≤ai≤500000.

输出

Output one integer in a line, indicating the answer.

样例输入 复制

3
2 3 4

样例输出 复制

3

提示

示例
输入
10
0 7 23 18 29 27 6 28 24 11
输出
15