Codeforces Round 228 (Div. 2)
A
Fox and Number Game
Codeforces
1000
原题
←B →
翻译中…

Fox Ciel is playing a game with numbers now.

翻译中…

Ciel has $*n*$ positive integers: $*x*_{1}$, $*x*_{2}$, ..., $*x*_{*n*}$. She can do the following operation as many times as needed: select two different indexes $*i*$ and $*j*$ such that $*x*_{*i*}$ > $*x*_{*j*}$ hold, and then apply assignment $*x*_{*i*}$ = $*x*_{*i*}$ - $*x*_{*j*}$. The goal is to make the sum of all numbers as small as possible.

翻译中…

Please help Ciel to find this minimal sum.

翻译中…

Input

翻译中…

The first line contains an integer $*n*$ ($2 ≤ *n* ≤ 100$). Then the second line contains $*n*$ integers: $*x*_{1}$, $*x*_{2}$, ..., $*x*_{*n*}$ ($1 ≤ *x*_{*i*} ≤ 100$).

翻译中…

Output

翻译中…

Output a single integer — the required minimal sum.

翻译中…

Note

翻译中…

In the first example the optimal way is to do the assignment: $*x*_{2}$ = $*x*_{2}$ - $*x*_{1}$.

翻译中…

In the second example the optimal sequence of operations is: $*x*_{3}$ = $*x*_{3}$ - $*x*_{2}$, $*x*_{2}$ = $*x*_{2}$ - $*x*_{1}$.

翻译中…

样例

Input #1
2
1 2
Output #1
2
InputCopy OutputCopy
Input #2
3
2 4 6
Output #2
6
InputCopy OutputCopy
Input #3
2
12 18
Output #3
12
InputCopy OutputCopy
Input #4
5
45 12 27 30 18
Output #4
15
InputCopy OutputCopy
题目信息
题号
389A
时间限制
1 s
内存限制
256 MB
标签
贪心
数学

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