3012.Maximum Value

Time Limit: 1s Memory Limit: 256MB

You are given a sequence a consisting of n integers. Find the maximum possible value of 3012_1.png (integer remainder of ai divided by aj), where 1 \le i,j \le n and ai \ge aj.

Input Format(From the terminal/stdin)

The first line contains integer n- the length of the sequence (1 \le n \le 2 \cdot 105).

The second line contains n space-separated integers ai (1 \le ai \le 106).

Output Format(To the terminal/stdout)

Print the answer to the problem.

Sample Input

Copy
3
3 4 5
 \n
 · · \n

Sample Output

Copy
2
 \n

Submit

请先 登录

© 2025 FAQs