Maximum Value

题意翻译

- 给定一个序列 $a_i$,请找出两个数 $i,j$,使得 $a_i \ge a_j$,并且使得 $a_i \bmod a_j$ 的值最大,求这个 $a_i\bmod a_j$ 的最大值。 - 对于 $100\%$ 的数据,$1 \le n \le 2\times 10^5$,$1 \le a_i \le 10^6$。 - Translated by 一只书虫仔 & QwQcOrz。

题目描述

You are given a sequence $ a $ consisting of $ n $ integers. Find the maximum possible value of ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF484B/f78b808248b814b54b378a7e1094ac9b8497b197.png) (integer remainder of $ a_{i} $ divided by $ a_{j} $ ), where $ 1<=i,j<=n $ and $ a_{i}>=a_{j} $ .

输入输出格式

输入格式


You are given a sequence $ a $ consisting of $ n $ integers. Find the maximum possible value of ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF484B/f78b808248b814b54b378a7e1094ac9b8497b197.png) (integer remainder of $ a_{i} $ divided by $ a_{j} $ ), where $ 1<=i,j<=n $ and $ a_{i}>=a_{j} $ .

输出格式


Print the answer to the problem.

输入输出样例

输入样例 #1

3
3 4 5

输出样例 #1

2