跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1855. Maximum Value

    ID: 1861 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>二分数学排序双指针算法思想编程与模拟提高难度共享题库Codeforces英文题面题目来源题面语言

Maximum Value

题目描述

B. Maximum Value
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a sequence a consisting of n integers. Find the maximum possible value of (integer remainder of ai divided by aj), where 1≤i,jn and aiaj.

Input

The first line contains integer n− the length of the sequence (1≤n≤2·105).

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

Output

Print the answer to the problem.

Examples
Input
3
3 4 5
Output
2

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1426 题。保留原作者与原赛事署名。