CF1113B Sasha and Magnetic Machines
题目描述
### 题意简述
有一个长度为$n$的正整数序列$a_{1..n}$。你可以对这个数列进行最多$1$次的如下操作:
- 选择$1 \leq i,j \leq n\ \ (i \neq j)$,并选择一个可以整除$a_i$的正整数$x$,然后将$a_i$变为$\frac{a_i}{x}$,将$a_j$变为$a_j \cdot x$。
问你操作后,该序列中所有数的和最小能达到多少。
输入格式
第一行输入$n\ (2\leq n\leq 5\cdot10^4)$,表示序列长度。
第二行输入$n$个空格隔开的正整数$a_i\ (1 \leq a_i \leq 100)$,描述序列中的元素。
输出格式
输出一个整数,操作后序列最小可能的数值和。
说明/提示
In the first example, the farmer can reduce the power of the $ 4 $ -th machine by $ 2 $ times, and increase the power of the $ 1 $ -st machine by $ 2 $ times, then the powers will be: $ [2, 2, 3, 2, 5] $ .
In the second example, the farmer can reduce the power of the $ 3 $ -rd machine by $ 2 $ times, and increase the power of the $ 2 $ -nd machine by $ 2 $ times. At the same time, the farmer can leave is be as it is and the total power won't change.
In the third example, it is optimal to leave it be as it is.