Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

B. Maximum Value

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given a sequence *a* consisting of *n* integers. Find the maximum possible value of (integer remainder of *a*_{i} divided by *a*_{j}), where 1 ≤ *i*, *j* ≤ *n* and *a*_{i} ≥ *a*_{j}.

Input

The first line contains integer *n* — the length of the sequence (1 ≤ *n* ≤ 2·10^{5}).

The second line contains *n* space-separated integers *a*_{i} (1 ≤ *a*_{i} ≤ 10^{6}).

Output

Print the answer to the problem.

Examples

Input

3

3 4 5

Output

2

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/31/2020 04:16:39 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|