Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official.
×

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-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/10/2018 06:23:49 (d1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|