Codeforces Round 276 (Div. 1)
B
Maximum Value
Codeforces
2100
原题
← AC →
翻译中…

You are given a sequence $*a*$ consisting of $*n*$ integers. Find the maximum possible value of image (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.

翻译中…

样例

Input #1
3
3 4 5
Output #1
2
InputCopy OutputCopy
题目信息
题号
484B
时间限制
1 s
内存限制
256 MB
标签
二分
数学
排序
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。