#Lutece2337. %%BlackRed·Z

%%BlackRed·Z

Migrated from Lutece 2337 %%BlackRed·Z

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

pic

众所周知,ICPCer 的一项传统艺能就是 %\% (mó)。当我们面对大佬的时候,经常会膜一下表示我们的敬意。而当我们面对大数的时候,也经常会模一下表示我们对 OJ 的敬意。

模运算定义:amodb=ca \bmod b = c 表示 aa 除以 bb 余数为 cc。现在我们有 nn 个正整数,第 ii 个数为 aia_i。对于一个非负整数 xxf(x)=i=1n(xmodai)f(x)=\displaystyle \sum^{n}_{i=1}{(x \bmod a_i)}。爱思考的 OrangeRain 想找到一个 xx,使得 f(x)f(x) 最大,请你告诉他 f(x)f(x) 最大是多少。

Input

第一行包含正整数 nn (2n30002 \leq n \leq 3000)。

第二行包含 nn 个正整数,第 ii 个数为 aia_i (2ai1052 \leq a_i \leq 10^5)。

Output

输出最大的 f(x)f(x)

Samples

5
7 46 11 20 11
90

Resources

电子科技大学第十一届 ACM 趣味程序设计竞赛