题库练习 Sasha and Magnetic Machines
← 上一题 下一题 →

A12451 | Sasha and Magnetic Machines

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

One day Sasha visited the farmer 2D and his famous magnetic farm. On this farm, the crop grows due to the influence of a special magnetic field. Maintaining of the magnetic field is provided by $n$ machines, and the power of the $i$ -th machine is $a_i$ .

This year 2D decided to cultivate a new culture, but what exactly he didn't say. For the successful growth of the new culture, it is necessary to slightly change the powers of the machines. 2D can at most once choose an arbitrary integer $x$ , then choose one machine and reduce the power of its machine by $x$ times, and at the same time increase the power of one another machine by $x$ times (powers of all the machines must stay positive integers). Note that he may not do that if he wants. More formally, 2D can choose two such indices $i$ and $j$ , and one integer $x$ such that $x$ is a divisor of $a_i$ , and change powers as following: $a_i = \frac{a_i}{x}$ , $a_j = a_j \cdot x$

Sasha is very curious, that's why he wants to calculate the minimum total power the farmer can reach. There are too many machines, and Sasha can't cope with computations, help him!

输入格式

The first line contains one integer $n$ ( $2 \le n \le 5 \cdot 10^4$ ) — the number of machines.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \le a_i \le 100$ ) — the powers of the machines.

输出格式

Print one integer — minimum total power.

输入输出样例

输入 #1
5
1 2 3 4 5
输出 #1
14
输入 #2
4
4 2 4 4
输出 #2
14
输入 #3
5
2 4 2 3 7
输出 #3
18
C++ 编辑器
输入
输出