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

#F1855. Maximum Value

  • ID: 1861
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:提高
  • 上传者:
  • 二分
  • 数学
  • 排序
  • 双指针
  • 算法思想
  • 编程与模拟
  • 提高
  • 难度
  • 共享题库
  • 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,j≤n and ai≥aj.

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 题。保留原作者与原赛事署名。