You are given a array A of size N. Lets see if you can find the maximum value of Ai % Aj such that Aj <= Ai and 1 <= i,j <= N.
Input
The first line contains integer N — the length of the sequence.
The second line contains N space-separated integers Ai
Output
Print the answer to the problem in one line
Constrains
1 <= N <= 5*105
1 <= ai <= 106