You are given a sequence a consisting of n integers. Find the maximum possible value of (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.
Input
The first line contains integer n — the length of the sequence (1 ≤ n ≤ 2·105).
The second line contains n space-separated integers ai (1 ≤ ai ≤ 106).
Output
Print the answer to the problem.
Examples
Input
3 3 4 5
Output
2
发现纯暴力绝对不行的
由于由于求的是余数
因此只需要二分出对于小于每个倍数的最大值即可
但是看似复杂度似乎很高 实则内层循环求和之后是ln(n)
所以该算法分复杂度是o(n*log(n)*log(n))