Codeforces Round 376 (Div. 2)
F
Video Cards
Codeforces
1900
原题
← E→
翻译中…

Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated.

翻译中…

There are $*n*$ video cards in the shop, the power of the $*i*$-th video card is equal to integer value $*a*_{*i*}$. As Vlad wants to be sure the new game will work he wants to buy not one, but several video cards and unite their powers using the cutting-edge technology. To use this technology one of the cards is chosen as the leading one and other video cards are attached to it as secondary. For this new technology to work it's required that the power of each of the secondary video cards is divisible by the power of the leading video card. In order to achieve that the power of any secondary video card can be reduced to any integer value less or equal than the current power. However, the power of the leading video card should remain unchanged, i.e. it can't be reduced.

翻译中…

Vlad has an infinite amount of money so he can buy any set of video cards. Help him determine which video cards he should buy such that after picking the leading video card and may be reducing some powers of others to make them work together he will get the maximum total value of video power.

翻译中…

Input

翻译中…

The first line of the input contains a single integer $*n*$ ($1 ≤ *n* ≤ 200 000$) — the number of video cards in the shop.

翻译中…

The second line contains $*n*$ integers $*a*_{1}$, $*a*_{2}$, ..., $*a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 200 000$) — powers of video cards.

翻译中…

Output

翻译中…

The only line of the output should contain one integer value — the maximum possible total power of video cards working together.

翻译中…

Note

翻译中…

In the first sample, it would be optimal to buy video cards with powers $3$, $15$ and $9$. The video card with power $3$ should be chosen as the leading one and all other video cards will be compatible with it. Thus, the total power would be $3 + 15 + 9 = 27$. If he buys all the video cards and pick the one with the power $2$ as the leading, the powers of all other video cards should be reduced by $1$, thus the total power would be $2 + 2 + 14 + 8 = 26$, that is less than $27$. Please note, that it's not allowed to reduce the power of the leading video card, i.e. one can't get the total power $3 + 1 + 15 + 9 = 28$.

翻译中…

In the second sample, the optimal answer is to buy all video cards and pick the one with the power $2$ as the leading. The video card with the power $7$ needs it power to be reduced down to $6$. The total power would be $8 + 2 + 2 + 6 = 18$.

翻译中…

样例

Input #1
4
3 2 15 9
Output #1
27
InputCopy OutputCopy
Input #2
4
8 2 2 7
Output #2
18
InputCopy OutputCopy
题目信息
题号
731F
时间限制
1 s
内存限制
256 MB
标签
暴力
数据结构
模拟
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。