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!


-----Input-----

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.


-----Output-----

Print one integer — minimum total power.


-----Examples-----
Input
5
1 2 3 4 5

Output
14

Input
4
4 2 4 4

Output
14

Input
5
2 4 2 3 7

Output
18



-----Note-----

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.

Difficulty: EASY
Tags: Number theory

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import math

def deli(x):
	b = []
	for i in range(2, x // 2 + 6):
		if x % i == 0:
			b.append(i)
	b.append(x)
	return b
n = int(input())
a = list(map(int, input().split()))
a.sort()
mini = min(a)
ans = 0
for i in range(n):
	if a[i] != mini:
		c = deli(a[i])
		for j in c:
			fr = mini + a[i]
			tec = mini * j + a[i] // j
			if fr - tec > ans:
				ans = fr - tec
print(sum(a) - ans)


import math

def __starting_point():
	n = int(input())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	b = sum(a)
	a = list(set(a))
	n = len(a)
	improv = 0
	for i in range(n):
		for j in range(n):
			if a[i] < a[j]:
				found = False
				k = 2
				current = 0
				while not found:
					if a[j] % k == 0:
						found = True
						current = max(a[i] + a[j] - a[i] * k - a[j] // k, current)
					if found and k < math.sqrt(a[j] / a[i]):
						found = False
					k = k + 1
				improv = max(improv, current)
	print(b - improv)
__starting_point()


def m(a, b):
	(a, b) = (max(a, b), min(a, b))
	_max = -10000
	for i in range(1, a + 1):
		if a % i == 0:
			temp = a // i * (i - 1) + b * (1 - i)
			if temp > _max:
				_max = temp
	return _max
n = input()
n = int(n)
_ = input()
a = _.split()
a = [int(_) for _ in a]
answer = sum(a)
dic = [False] * 100
for i in a:
	dic[i - 1] = True
_max = -10000
for i in range(99):
	if not dic[i]:
		continue
	for j in range(i + 1, 100):
		if not dic[j]:
			continue
		temp = m(i + 1, j + 1)
		if temp > _max:
			_max = temp
if _max <= 0:
	print(answer)
else:
	print(answer - _max)


n = int(input())
ai = list(map(int, input().split()))
ai.sort()
ans = sum(ai)
ans3 = ans
for j in range(1, n):
	for i in range(1, 11):
		ans2 = ans3
		if ai[j] % i == 0:
			ans2 -= ai[j] + ai[0]
			ans2 += ai[0] * i + ai[j] // i
		ans = min(ans, ans2)
print(ans)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial

def binNumber(n, size=1):
	return bin(n)[2:].zfill(size)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isp():
	return list(map(int, input().split()))

def sti():
	return str(input())

def par(a):
	return ' '.join(list(map(str, a)))

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)

def __starting_point():
	n = ini()
	a = iar()
	mi = min(a)
	mis = sum(a)
	mas = mis
	for i in a:
		if i == mi:
			continue
		j = 2
		while j * j <= i:
			if i % j == 0:
				c1 = i // j
				c2 = mi * j
				x = mas - mi - i + c1 + c2
				if x < mis:
					mis = x
				if j != i // j:
					k = i // j
					c1 = i // k
					c2 = mi * k
					x = mas + c1 + c2 - mi - i
					if x < mis:
						mis = x
			j += 1
	print(mis)
__starting_point()


n = int(input())
a = list(sorted([int(x) for x in input().split()]))
mmm = 0
for i in range(1, n):
	for j in range(2, a[i] - 1):
		if a[i] % j == 0:
			mmm = max(mmm, (j - 1) * (a[i] // j) - j * a[0] + a[0])
print(sum(a) - mmm)


import math
import bisect
import heapq

def primeFactors(n):
	if n == 1:
		return []
	fact = []
	while n % 2 == 0:
		fact.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			fact.append(int(i))
			n = n / i
	if n > 2:
		fact.append(int(n))
	return fact
n = int(input().strip())
powers = list(map(int, input().strip().split()))
full = sum(powers)
powers = list(set(powers))
n = len(powers)
powers.sort(reverse=True)
best_impr = 0
already_done = {}
for i in range(n - 1):
	for j in range(i + 1, n):
		v1 = powers[i]
		v2 = powers[j]
		if (v1, v2) in already_done:
			continue
		orig = v1 + v2
		for d in range(2, int(math.sqrt(v1 + 1)) + 1):
			if v1 % d == 0:
				impr = orig - int(v1 / d) - v2 * d
				if impr > best_impr:
					best_impr = impr
		already_done[v1, v2] = True
print(full - best_impr)


n = int(input())
arr = list(map(int, input().split()))
ans = sum(arr)
su = ans
arr.sort()
for i in range(1, len(arr)):
	cur = arr[i]
	x = 1
	while x * x <= cur:
		if cur % x == 0:
			ans = min(ans, su - arr[0] - cur + cur // x + arr[0] * x)
			y = cur // x
			ans = min(ans, su - arr[0] - cur + cur // y + arr[0] * y)
		x += 1
print(ans)


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
n = nn()
l = lm()
l.sort()
s = sum(l)
ms = s
for num in l:
	for j in range(1, num // 2 + 1):
		if num % j == 0:
			newnum = num // j
			newsum = s - num + newnum - l[0] + j * l[0]
			ms = min(newsum, ms)
print(ms)


from sys import stdin, stdout
input = stdin.readline
p = [0 for i in range(90000)]

def sieve(n):
	i = 2
	while i * i <= n:
		if p[i] == 0:
			for j in range(i * i, n + 1, i):
				p[i] = 1
		i += 1
p[2] = 0
sieve(90000)
(x, a) = (int(input()), list(map(int, input().split())))
K = 0
for i in a:
	K = K + i
F = 0
for i in a:
	if p[i]:
		F = 1
if F == 0:
	(print(K), exit())
a.sort()
(s, l, r) = (1000000000.0, 0, x - 1)
while 1:
	if l >= r:
		break
	while p[a[r]] == 0:
		r -= 1
	if l >= r:
		break
	(t, ok) = (a[r], a[r] + a[l])
	i = 2
	while i * i <= t:
		if t % i == 0:
			ok = min(ok, t // i + a[l] * i)
		i += 1
	s = min(s, K - (a[r] + a[l]) + ok)
	r -= 1
print(s)


n = int(input())
a = list(map(int, input().split()))
rec = [0] * n
mi = float('inf')
index = -1
for i in range(n):
	if a[i] < mi:
		mi = a[i]
		index = i
for i in range(n):
	for j in range(2, int(100 ** 0.5) + 1):
		if j >= a[i]:
			break
		if a[i] % j == 0:
			rec[i] = max(rec[i], a[i] - a[i] // j - (min(mi, a[i] // j) * j - min(mi, a[i] // j)))
print(sum(a) - max(rec))


n = int(input())
a = sorted(list(map(int, input().split())))
s = sum(a)
ans = s
for i in a:
	for j in range(1, i + 1):
		if i % j == 0:
			temp = (j - 1) * (i // j - a[0])
			ans = min(ans, s - temp)
print(ans)


b = []
input()
a = [int(i) for i in input().split()]
m = sum(a)
for i in range(len(a)):
	if a[i] not in b:
		for x in range(2, a[i]):
			if a[i] % x == 0:
				if sum(a) - min(a) - a[i] + a[i] / x + min(a) * x < m:
					m = sum(a) - min(a) - a[i] + a[i] / x + min(a) * x
	b.append(a[i])
print(int(m))


n = int(input())
a = list(map(int, input().split()))
import math as m

def flist(k):
	d = [1]
	i = 2
	while i <= m.sqrt(k):
		if k % i == 0:
			d.append(i)
		i += 1
	d.append(k)
	return d
a.sort()
s = sum(a)
c = []
for i in range(1, n):
	f = flist(a[i])
	for j in f:
		b = a[0] * j + a[i] // j
		c.append(s - (a[0] + a[i]) + b)
print(min(min(c), s))


import math
n = int(input())
l = list(map(int, input().split()))
mn = min(l)
s = sum(l)
res = s
se = set(l)
le = len(se)
if le == 1:
	print(s)
else:
	for i in range(n):
		for j in range(1, l[i] + 1):
			if l[i] % j != 0:
				continue
			cur = s - mn - l[i]
			cur += math.floor(l[i] // j) + math.floor(mn * j)
			res = min(res, cur)
	print(res)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
mx = 0
n = iinp()
arr = lmp()
mn = min(arr)
for num in arr:
	x = num + mn
	for i in range(1, int(sqrt(num)) + 1):
		if num % i == 0:
			mx = max(mx, x - num // i - i * mn)
			if i * i != num:
				mx = max(mx, x - i - num // i * mn)
print(sum(arr) - mx)


def foo(a0, b):
	minval = 10000
	for x in range(2, b // 2 + 1):
		if b % x != 0:
			continue
		val = a0 * x + b // x
		if val >= a0 + b:
			continue
		elif val < minval:
			minval = val
	if a0 + b - minval < 0:
		return 0
	else:
		return a0 + b - minval
n = int(input())
a = [int(x) for x in input().split()]
asum = sum(a)
a = list(set(a))
a.sort()
maxdiff = 0
for i in range(len(a)):
	diff = foo(a[0], a[i])
	if diff > maxdiff:
		maxdiff = diff
print(asum - maxdiff)


n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
mi = arr[-1]
mis = 0
for i in arr:
	for e in range(2, i):
		if i % e != 0:
			continue
		if mi * e - mi - (i - i / e) < mis:
			mis = mi * e - mi - (i - i / e)
print(int(sum(arr) + mis))


import math

def printDivisors(n):
	lol = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				lol.append(i)
			else:
				lol.append(i)
				lol.append(n / i)
		i = i + 1
	return lol
n = int(input())
a = [int(o) for o in input().split()]
a = sorted(a)
d = []
sa = sum(a)
sa1 = sa
d.append(sum(a))
aa = a[:]
for i in range(1, n):
	u = printDivisors(a[i])
	for j in u:
		sa += a[0] * j - a[0]
		sa -= a[i] - a[i] // j
		d.append(sa)
		sa = sa1
print(int(min(d)))


import math

def prime(n):
	if n == 1 or n == 2 or n == 3:
		return True
	i = int(math.sqrt(n))
	for j in range(2, i + 1):
		if n % j == 0:
			return False
	else:
		return True
d = {}
for _ in range(4, 101):
	if prime(_):
		continue
	d[_] = []
	for j in range(2, int(math.sqrt(_)) + 1):
		if _ % j == 0:
			d[_].append(j)
			d[_].append(_ // j)
n = int(input())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
dec = 0
for _ in a:
	if prime(_):
		continue
	for di in d[_]:
		dec = max(dec, _ - _ // di + (a[0] - a[0] * di))
print(s - dec)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
base_sum = sum(a)
smallest = a[0]
min_sum = sum(a)
if n == 1:
	print(min_sum)
	exit()
seen = set()
for x in a[1:]:
	if x in seen:
		continue
	seen.add(x)
	without = base_sum - a[0] - x
	for div in range(2, x + 1):
		if x % div == 0:
			min_sum = min(min_sum, without + smallest * div + x // div)
print(min_sum)


from itertools import combinations, permutations
from collections import defaultdict
import math
import sys
import os

def solution(n, a):
	sm = sum(a)
	ans = sm
	a.sort()
	for i in range(1, n):
		for x in range(a[i] - 1, 1, -1):
			if a[i] % x == 0:
				ans = min(ans, sm - a[i] - a[0] + a[i] / x + a[0] * x)
	return ans

def main():
	n = int(input().strip())
	arr = list(map(int, input().strip().split()))
	print(int(solution(n, arr)))
main()


n = int(input())
mas = list(map(int, input().split()))
mas.sort()
ans = sum(mas)
ans1 = sum(mas)
mass = []
for i in range(n):
	ch = 2
	a = []
	while ch * ch <= mas[i]:
		if mas[i] % ch == 0:
			a.append(ch)
		ch += 1
	mass.append(a)
for i in range(n - 1, 0, -1):
	for j in range(len(mass[i])):
		ans1 = min(ans1, ans - mas[0] - mas[i] + mas[0] * mass[i][j] + mas[i] // mass[i][j])
print(ans1)


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
L = set(l)
m = min(L)
r = 0
for x in L:
	d = 2
	while x / d > m:
		if x % d == 0:
			a = x // d + m * d - x - m
			if r == 0:
				r = a
			if a < r:
				r = a
		d += 1
print(s + r)


def minim(a1, aj):
	temp = int((aj / a1) ** 0.5)
	tem2 = temp + 1
	while aj % temp != 0:
		temp = temp - 1
	min1 = a1 * temp + int(aj / temp)
	min2 = min1 + 1
	while aj % tem2 != 0 and tem2 < aj:
		tem2 = tem2 + 1
	if tem2 <= aj:
		min2 = a1 * tem2 + int(aj / tem2)
	return min(min1, min2)
n = int(input())
x = list(map(int, input().split()))
x.sort()
min0 = sum(x)
min_ans = min0
for j in range(1, n):
	rem = min0 - x[0] - x[j]
	if min_ans > rem + minim(x[0], x[j]):
		min_ans = rem + minim(x[0], x[j])
print(min_ans)


import math
import bisect

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def printDivisors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return set(factors)
n = int(input())
arr = list_input()
arr.sort(reverse=True)
summ = min_sum = sum(arr)
for i in range(n - 1):
	num = arr[i]
	factors = list(printDivisors(num))
	if len(factors) > 2:
		factors.sort()
		factors.pop(0)
		factors.pop(-1)
		for j in factors:
			temp = summ - arr[i] - arr[-1]
			first = arr[i] // j
			last = arr[-1] * j
			temp += first + last
			min_sum = min(min_sum, temp)
print(min_sum)


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
if n == 1:
	print(s)
	exit()
ans = s
c = {}
for i in range(n):
	if a[i] not in c:
		c[a[i]] = 0
	c[a[i]] += 1
ds = {}
for i in range(1, 102):
	ds[i] = []
	for j in range(1, i + 1):
		if i % j == 0:
			ds[i].append(j)
for v1 in c.keys():
	for v2 in c.keys():
		if v1 == v2 and c[v1] == 1:
			continue
		for d in ds[v1]:
			ch = -(v1 - v1 // d) + (v2 * d - v2)
			ans = min(ans, s + ch)
print(ans)


n = int(input())
a = map(int, input().split())
c = [0] * 105
ans = 0
sum = 0
for x in a:
	c[x] += 1
	sum += x
ans = sum
for i in range(101):
	for j in range(i + 1, 101):
		if c[i] > 0 and c[j] > 0:
			for k in range(1, j):
				if j % k == 0:
					ans = min(ans, sum - i - j + j // k + i * k)
print(ans)


import sys
try:
	sys.stdin = open('in.in', 'r')
	sys.stdout = open('out.out', 'w')
except:
	pass
n = int(input())
a = list(map(int, input().split()))
a.sort()
suma = sum(a)
ans = 9999999999999999999999999
for i in range(n):
	cur = a[i]
	for j in range(1, cur + 1):
		if cur % j != 0:
			continue
		minx = a[0] if i != 0 else a[1]
		tsum = suma - a[i] - minx + a[i] // j + minx * j
		ans = min(ans, tsum)
print(ans)


def getMin(i):
	a = pref[i - 1] if i - 1 >= 0 else 10 ** 10
	b = suf[i + 1] if i + 1 < n else 10 ** 10
	return min(a, b)
n = int(input())
v = [int(i) for i in input().split()]
pref = [0] * n
suf = [0] * n
pref[0] = v[0]
suf[n - 1] = v[n - 1]
j = n - 2
for i in range(1, n):
	pref[i] = min(pref[i - 1], v[i])
	suf[j] = min(suf[j + 1], v[j])
	j -= 1
tot = sum(v)
ans = tot
for i in range(n):
	div = 1
	while div * div <= v[i]:
		if v[i] % div == 0:
			mn = getMin(i)
			ans = min(ans, tot - v[i] - mn + v[i] / div + mn * div)
		div += 1
print(int(ans))


def primes(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if n % i == 0:
			return False
	return True

def factors(n):
	temp = []
	for i in range(2, n):
		if n % i == 0:
			temp.append(i)
	return temp
n = int(input())
l = list(map(int, input().split()))
l.sort()
m = sum(l)
small = m
for i in range(n - 1, -1, -1):
	if not primes(l[i]):
		f = factors(l[i])
		for j in f:
			if m - l[i] * (j - 1) // j + l[0] * (j - 1) < small:
				small = m - l[i] * (j - 1) // j + l[0] * (j - 1)
print(small)


input()
a = [*map(int, input().split())]
m = min(a)
print(sum(a) - max((y + m - y // x - m * x for y in set(a) for x in range(1, int(y ** 0.5) + 1) if y % x == 0)))


import sys
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import gcd
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7

def hnbhai():
	n = sb()
	a = sd()
	b = list(set(a))
	sum_ = sum(a)
	min_ = min(a)
	minus = 0
	for i in b:
		fact = 2
		while i // fact > min_:
			if i % fact == 0:
				temp = i // fact + min_ * fact - i - min_
				minus = min(minus, temp)
			fact += 1
	print(sum_ + minus)
for _ in range(1):
	hnbhai()


def GetFactors(n):
	factors = []
	for i in range(1, n + 1):
		if n % i == 0:
			factors.append(i)
	return factors

def main():
	n = int(input())
	power = list(map(int, input().split()))
	power.sort()
	factors = []
	total_power = sum(power)
	min_power = float('inf')
	for i in range(n - 1, -1, -1):
		factors = GetFactors(power[i])
		for k in factors:
			p = total_power - power[0] - power[i]
			p += int(power[i] / k)
			p += power[0] * k
			if p < min_power:
				min_power = p
	if min_power == float('inf'):
		print(total_power)
		return
	print(min_power)
main()


n = input()
a = list(map(int, input().split()))
a_min = min(a)
a_sum = sum(a)
ans = -2
for i in a:
	for j in range(1, i + 1):
		if i % j == 0:
			ans = max(i + a_min - a_min * j - i // j, ans)
print(a_sum - ans)


import math

def replace(a, b):
	if a == b:
		return a + b
	if a > b:
		atemp = a
		a = b
		b = atemp
	x = a + b
	for i in range(1, 1 + math.ceil(math.sqrt(b))):
		if b % i == 0:
			x = min(x, a * i + b // i)
	return x
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print(sum(a))
else:
	a = sorted(a)
	sum1 = sum(a)
	rq = 0
	for i in range(n - 1, -1, -1):
		rq = min(rq, replace(a[0], a[i]) - a[0] - a[i])
	print(sum1 + rq)


def factor(num):
	if num > 2:
		f = []
		for i in range(2, int(num ** 0.5) + 1):
			if num % i == 0:
				f.append(i)
		f.append(num)
		return f
	elif num == 0:
		return []
	elif num == 1:
		return []
	elif num == 2:
		return [2]
n = int(input())
a = list(map(int, input().split()))
maxi = max(a) + 1
mi = a.index(min(a))
fact = []
s = sum(a)
ts = s - a[mi]
ttts = s
for i in range(0, maxi):
	fact.append(factor(i))
done = set()
for i in range(0, n):
	if i != mi and a[i] not in done:
		done.add(a[i])
		for j in fact[a[i]]:
			tts = ts - a[i] + a[i] // j + a[mi] * j
			ttts = min(ttts, tts)
print(ttts)


I = lambda : map(int, input().split())
n = int(input())
li = list(I())
ma = 0
maxx = max(li)
minn = min(li)
if maxx == minn:
	exit(print(sum(li)))
l = []
for i in li:
	if i != minn:
		t = int(i ** 0.5) + 1
		for j in range(2, t + 1):
			if i % j == 0:
				ma = max(ma, i + minn - i // j - minn * j)
print(sum(li) - ma)


import math

def printDivisors(n):
	lol = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				lol.append(i)
			else:
				lol.append(i)
				lol.append(n / i)
		i = i + 1
	return lol
n = int(input())
a = [int(o) for o in input().split()]
a = sorted(a)
bob = a[:]
ansarr = []
sumfinal = sum(a)
sum1 = sumfinal
ansarr.append(sum(a))
aa = a[:]
sum1 = sumfinal - 0
bob.sort()
for i in range(1, n):
	u = printDivisors(a[i])
	for j in range(len(u)):
		bob[0] = 0
		sumfinal += a[0] * u[j] - a[0]
		bob[0] = 1
		sumfinal -= a[i] - a[i] / u[j]
		bob[0] = 2
		ansarr.append(sumfinal)
		bob[0] = 0
		sumfinal = sum1
		bob[0] = 0
uhoy = 9999999999
for i in range(len(ansarr)):
	if ansarr[i] < uhoy:
		uhoy = ansarr[i]
print(int(uhoy))


n = int(input())
a = list(map(int, input().split(' ')))
a = sorted(a)
mn = a[0]
sm = sum(a)
tot = sm
for i in range(1, n):
	b = []
	j = 2
	while j * j <= a[i]:
		if j * j == a[i]:
			b.append(j)
		if a[i] % j == 0:
			b.append(j)
			b.append(a[i] // j)
		j += 1
	for j in b:
		ts = sm
		ts -= a[i]
		ts -= mn
		ts += a[i] // j
		ts += mn * j
		tot = min(tot, ts)
print(tot)


def sasha_problem():
	max_num = 110
	count = []
	n = eval(input())
	sum = 0
	answer = 0
	input_num = input().split(' ')
	for i in range(max_num):
		count.append(0)
	for i in range(len(input_num)):
		input_num[i] = eval(input_num[i])
		sum += input_num[i]
		count[input_num[i]] += 1
	for i in range(1, 101):
		for j in range(i + 1, 101):
			for k in range(2, 101):
				if count[i] and count[j] and (j % k == 0):
					answer = max(answer, int(j - j / k - (i * k - i)))
	answer = sum - answer
	print(answer)
	return
sasha_problem()


N = int(input())
list = list(map(int, input().split()))
list.sort()
sumi = sum(list)
difference = 0
for i in range(1, N):
	for x in range(1, list[i] // 2 + 1):
		if list[i] // x == list[i] / x and list[0] + list[i] - (list[0] * x + list[i] / x) > difference:
			difference = list[0] + list[i] - (list[0] * x + list[i] / x)
print(int(sumi - difference))


import math

def alld(x):
	b = []
	for i in range(2, x // 2 + 5):
		if x % i == 0:
			b.append(i)
	b.append(x)
	return b
n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
mn = min(a)
rz = 0
for i in range(n):
	if a[i] != mn:
		c = alld(a[i])
		for j in c:
			stc = mn + a[i]
			tc = mn * j + a[i] // j
			if stc - tc > rz:
				rz = stc - tc
print(sum(a) - rz)
exit()


from operator import itemgetter
from math import sqrt
n = int(input())
alist = list(map(int, input().split()))
tot = sum(alist)
aset = set(alist)
m = min(aset)
tmp = []
for i in aset:
	for j in range(1, i + 1):
		if i % j == 0:
			tmp.append(m * j + i // j - m - i)
print(tot + min(tmp))


n = int(input())
a = list(map(int, input().split()))
m = min(a)
a.sort(reverse=True)
count = 0
k = sum(a)
l = []
l.append(k)
for i in range(len(a)):
	for j in range(1, a[i]):
		if a[i] % j == 0:
			count = 1
			ans = k - a[i] + a[i] // j - m + m * j
			l.append(ans)
print(min(l))


def calc_min_power(a):
	_min = float('inf')
	_sum = 0
	for v in a:
		_min = min(_min, v)
		_sum += v
	min_power = _sum
	for v in a:
		for d in get_divisors(v):
			min_power = min(min_power, _sum - v + v // d - _min + _min * d)
	return min_power

def get_divisors(v):
	divisors = set()
	i = 2
	while i ** 2 <= v:
		if v % i == 0:
			divisors.add(i)
			divisors.add(v // i)
		i += 1
	return divisors
input()
a = [int(v) for v in input().split()]
print(calc_min_power(a))


n = int(input())
l = sorted(map(int, input().split()))
s = sum(l)
res = s
for a in l:
	for x in range(1, a + 1):
		if a % x == 0:
			e = (x - 1) * (a // x - l[0])
			res = min(res, s - e)
print(res)


input()
machines = list(map(int, input().split()))
machines.sort()
min_power = machines[0]
initial_sum = sum(machines)
best_sum = initial_sum
for max_power in machines:
	for i in range(1, max_power // 2 + 1):
		if max_power % i == 0:
			new_sum = initial_sum - max_power + max_power // i - min_power + min_power * i
			best_sum = min(best_sum, new_sum)
print(best_sum)


n = int(input())
a = [int(i) for i in input().split(' ')]
a.sort()
import math

def cal(n):
	res = []
	i = 1
	while i * i <= n:
		if n % i == 0:
			res.append(i)
			if i != n // i:
				res.append(n // i)
		i += 1
	return res
	return res

def he(a):
	if len(a) == 1:
		return a[0]
	res = sums = sum(a)
	for i in range(1, len(a)):
		tmp = cal(a[i])
		for j in tmp:
			res = min(res, sums + a[i] // j - a[i] + a[0] * (j - 1))
	return res
print(he(a))


def divisor(i, a):
	k = 1000
	for j in range(2, i // 2 + 1):
		if i % j == 0:
			k = min(k, a * j + i // j)
	return k
n = int(input())
lis = list(map(int, input().split()))
s = set(lis)
s = sorted(s)
ans = sum(lis)
aa = sum(lis)
for i in range(1, len(s)):
	ans = min(ans, aa + divisor(s[i], s[0]) - s[0] - s[i])
print(ans)


import math

def fact(x):
	ans = []
	for i in range(1, int(math.sqrt(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if i != x // i:
				ans.append(x // i)
	return ans
fac = []
for i in range(1, 101):
	t = fact(i)
	fac.append(t)
a = int(input())
z = list(map(int, input().split()))
z.sort()
r = sum(z)
mini = math.inf
for i in range(len(z) - 1, -1, -1):
	gam = fac[z[i] - 1]
	for j in range(len(gam)):
		mini = min(mini, r - z[i] + z[i] // gam[j] - z[0] + z[0] * gam[j])
print(mini)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = sum(l)
ans = s
for i in range(1, n):
	j = 1
	while j <= l[i]:
		x = s
		if l[i] % j == 0:
			x = x + l[i] // j - l[i]
			x = x - l[0] + l[0] * j
		j += 1
		ans = min(ans, x)
print(ans)


import sys
from math import *
from fractions import gcd
readints = lambda : list(map(int, input().strip('\n').split()))
n = int(input())
a = list(readints())
s = sum(a)
m = min(a)
best = s
for x in a:
	for d in range(1, x + 1):
		if x % d == 0:
			dx = x / d
			dm = m * d
			s2 = s - x - m + dx + dm
			best = min(best, s2)
best = int(best)
print(best)


n = int(input())
a = list(map(int, input().split()))
idx = -1
min_el = 101
for (i, el) in enumerate(a):
	if el < min_el:
		min_el = el
		idx = i
sum_a = sum(a)
res = sum_a
for (i, el) in enumerate(a):
	if i != idx:
		for x in range(2, el + 1):
			if el % x == 0:
				res = min(res, sum_a + (x - 1) * (min_el - el // x))
print(res)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	(ret, sumx, minx) = (sum(a), sum(a), min(a))
	for d in range(2, 101):
		for x in a:
			if x % d == 0:
				temp = sumx - (x - x // d) + (minx * d - minx)
				ret = min(temp, ret)
	print(ret)
main()


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
mx = 10 ** 7 + 1
n = I()
a = list(R())
r = s = sum(a)
mn = min(a)
for i in a:
	for j in range(2, i):
		if not i % j:
			r = min(r, s - i - mn + i // j + mn * j)
print(r)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
s = sum(a)
x = s
for i in a:
	for j in range(1, i + 1):
		if i % j == 0 and x - (i - i // j) + m * j - m < s:
			s = x - (i - i // j) + m * j - m
print(s)


n = int(input())
x = input()
x = x.split()
a = []
minn = 1001
sum = 0
for i in range(0, n):
	a.append(int(x[i]))
	minn = min(minn, int(x[i]))
	sum = sum + int(x[i])
a = sorted(a, reverse=1)
ans = sum
for i in range(0, n):
	for j in range(2, a[i] + 1):
		if a[i] % j == 0:
			ans = min(ans, sum - a[i] - minn + a[i] // j + minn * j)
print(ans)


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
x = 1
sum1 = sum(lst)
min1 = 2 * sum1
Max1 = lst[-1]
Min1 = lst[0]
Min = Min1
for i in range(len(lst[1:])):
	Max = lst[-1 - i]
	if Max == Min:
		break
	sum1 -= Max + Min
	for j in range(1, Max):
		if Max % j == 0:
			if sum1 + Max + Min > sum1 + Max // j + Min * j and min1 > sum1 + Max // j + Min * j:
				Max1 = Max
				Min1 = Min
				min1 = sum1 + Max // j + Min * j
				x = j
	sum1 += Max + Min
sum1 -= Max1 + Min1
sum1 += Max1 // x + Min1 * x
print(sum1)


n = int(input())
nums = list(map(int, input().split()))
ans = 100 * n
numsum = sum(nums)
maxn = max(nums)
minn = min(nums)
for d in range(1, maxn + 1):
	maxdiv = 0
	for i in range(n):
		if nums[i] % d == 0:
			if nums[i] > maxdiv:
				maxdiv = nums[i]
	change = (d - 1) * minn + maxdiv // d - maxdiv
	ans = min(ans, numsum + change)
print(ans)


def fac(n):
	b = [1]
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			b.append(i)
			if i != n // i:
				b.append(n // i)
	return b
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
m = 10 ** 9
a.sort()
for i in a[::-1]:
	for j in fac(i):
		m = min(m, s + a[0] * j + i // j - a[0] - i)
print(m)


n = int(input())
mag = [int(x) for x in input().split()]
ferma = min(mag)
max_counter = 0
for item in mag:
	for i in range(1, item // 2 + 1):
		if item % i == 0:
			counter = item - item // i - ferma * i + ferma
			if counter > max_counter:
				max_counter = counter
print(sum(mag) - max_counter)


def factors(a):
	f = []
	for i in range(2, a):
		if a % i == 0:
			f.append(i)
	return f
n = int(input())
a = list(map(int, input().split()))
a.sort()
sm = sum(a)
ans = sm
i = n - 1
while i > 0:
	f = factors(a[i])
	if f:
		for j in f:
			(x, y) = (a[i] // j, a[0] * j)
			ans = min(ans, sm - a[i] - a[0] + x + y)
	i -= 1
print(ans)


import math

def factors(x):
	ans = []
	for i in range(2, math.floor(math.sqrt(x)) + 1):
		if x % i == 0:
			ans.append(i)
			other = x // i
			if other != i:
				ans.append(other)
	return ans
assert sorted(factors(50)) == [2, 5, 10, 25]
assert sorted(factors(16)) == [2, 4, 8]
assert sorted(factors(120)) == [2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60]

def solve(xs):
	nums = set()
	minimum = float('inf')
	best = 0
	for x in xs:
		nums.add(x)
		best += x
		minimum = min(minimum, x)
	best_reduction = 0
	for x in nums:
		if x != minimum:
			have = minimum + x
			for factor in factors(x):
				reduced = minimum * factor + x // factor
				best_reduction = max(best_reduction, have - reduced)
	return best - best_reduction
n = int(input())
xs = list(map(int, input().split()))[:n]
print(solve(xs))


n = int(input())
array = list(map(int, input().split()))
sums = 0
for i in array:
	sums += i
maxm = 0
array.sort(reverse=True)
i = 0
if array[0] == array[-1]:
	print(sums)
else:
	while i < len(array) - 1:
		j = 2
		while j < array[i] // 2 + 1:
			if array[i] % j == 0 and (i == 0 or array[i] != array[i - 1]):
				if array[-1] + array[i] - array[i] // j - array[-1] * j > maxm:
					maxm = array[-1] + array[i] - array[i] // j - array[-1] * j
				prod = array[i] // j
				if array[-1] + array[i] - array[i] // prod - array[-1] * prod > maxm:
					maxm = array[-1] + array[i] - array[i] // prod - array[-1] * prod
			j += 1
		i += 1
	print(sums - maxm)


n = int(input())
ln = sorted([int(a) for a in input().split(' ')])
ns = sum(ln)
sums = [ns]
mn = ln[0]
ns -= mn
for i in range(n - 1, 0, -1):
	p = ln[i]
	j = 1
	while j * j <= p:
		if p % j == 0:
			sums.append(ns + mn * j - p + p // j)
		j += 1
print(min(sums))


def get():
	return list(map(int, input().split()))

def pf(n):
	a = []
	i = 1
	while i * i < n:
		if n % i == 0:
			a += [i]
			a += [n // i]
		i += 1
	if i * i == n:
		a += [i]
	return a
n = int(input())
b = get()
c = list(set(b))
a = 101 * [0]
for i in range(1, 101):
	a[i] = pf(i)
s = sum(b)
c.sort()
m = c[0]
ans = 0
for i in c:
	for j in a[i]:
		ans = max(ans, (j - 1) * (i // j - m))
print(s - ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
sum = 0
for i in range(n):
	sum += a[i]
mn = sum
if n == 1:
	print(sum)
else:
	for i in range(1, n):
		for j in range(1, a[i] + 1):
			if j * j > a[i]:
				break
			if a[i] % j == 0:
				x = a[i] - int(a[i] / j)
				y = a[0] * j - a[0]
				mn = min(mn, sum - x + y)
				tmp = int(a[i] / j)
				x = a[i] - j
				y = a[0] * tmp - a[0]
				mn = min(mn, sum - x + y)
	print(mn)


n = int(input())
arr = list(map(int, input().split()))
d = dict()
for el in arr:
	d[el] = d.get(el, 0) + 1
min_ans = 0
for el1 in d:
	for el2 in d:
		if el1 != el2:
			for x in range(2, 101):
				if el1 % x == 0:
					min_ans = min(min_ans, el1 // x + el2 * x - el1 - el2)
print(sum(arr) + min_ans)


nb_monster = int(input())
powers = sorted([int(x) for x in input().split()])
curr = powers[0]
mins = 0
for p in powers:
	for j in range(1, int(p ** 0.5) + 1):
		if p % j == 0:
			cand = curr + p - (p // j + curr * j)
			mins = max(mins, cand)
print(sum(powers) - mins)


n = int(input())
a = list(map(int, input().split()))
flag = [True for i in range(101)]
a.sort()
for i in set(a):
	flag[i] = False
if a[0] == a[n - 1]:
	print(n * a[0])
else:
	currNum = -1
	currX = -1
	minA = a[0]
	ans = sum(a)
	currDelta = 0
	for i in range(100, 0, -1):
		if flag[i]:
			continue
		for j in range(1, i // 2 + 1):
			if i % j != 0:
				continue
			delta = i // j + minA * j - (i + minA)
			if currDelta > delta:
				currDelta = delta
	ans += currDelta
	print(ans)


import collections
import heapq
import bisect
import math
import time

class Solution2:

	def solve(self, A1, A2):
		pass

def gcd(a, b):
	if not b:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return b * a // gcd(b, a)

class Solution:

	def solve(self, powers):

		def find(n, curr_sum):
			for i in range(2, min(n + 1, int(math.sqrt(n)) + 2)):
				if n % i == 0:
					self.out = min(self.out, curr_sum + i * min_p - n + n // i)
					self.out = min(self.out, curr_sum + n // i * min_p - n + i)
		min_p = min(powers)
		curr_sum = sum(powers)
		self.out = curr_sum
		for power in powers:
			find(power, curr_sum - min_p)
		return self.out
sol = Solution()
sol2 = Solution2()
for test_case in range(1):
	N = input()
	b = [int(c) for c in input().split()]
	out = sol.solve(b)
	print(str(out))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
su = sum(arr)
mx = max(arr) // 2
ans = sum(arr)
for i in range(n - 1, -1, -1):
	for j in range(mx, 1, -1):
		if arr[i] % j == 0:
			summ = su
			summ -= arr[i]
			summ += arr[i] // j
			summ -= arr[0]
			summ += arr[0] * j
			if summ < ans:
				ans = summ
print(ans)


n = int(input())
a = list(map(int, input().split()))
total = sum(a)
mn = total
a = list(set(a))
a.sort()
for i in range(len(a) - 1, -1, -1):
	for j in range(2, a[i]):
		if a[i] % j == 0:
			x = a[i] / j
			mn = min(total - a[i] - a[0] + a[i] // x + a[0] * x, mn)
print(int(mn))


def solve(n, a):
	i = 0
	j = n - 1
	total = sum(a)
	res = total
	for j in range(1, n):
		p = float('inf')
		for x in range(2, int(a[j] ** 0.5) + 1):
			if a[j] % x != 0:
				continue
			p = min(p, a[j] // x + a[i] * x)
		q = a[i] + a[j]
		if p < q:
			res = min(res, total - (q - p))
	return res
n = int(input())
a = sorted(map(int, input().split()))
print(solve(n, a))


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
total = 0
d = collections.defaultdict(int)
n = ii()
arr = li()
for i in arr:
	d[i] += 1
	total += i
a = list(d.keys())
a = sorted(a, reverse=True)
mn = a[-1]
large = 0
for i in a:
	mx = i
	lst = []
	j = 2
	while j * j <= mx:
		if mx % j == 0:
			lst.append(j)
		j += 1
	for j in lst:
		if mx + mn - (mx // j + mn * j) > large:
			large = mx + mn - (mx // j + mn * j)
print(total - large)


input()
a = list(map(int, input().split()))
m = min(a)
print(sum(a) - max((i + m - i // j - m * j for i in set(a) for j in range(1, int(i ** 0.5) + 1) if i % j == 0)))


n = int(input())
p = list(map(int, input().split()))
p.sort(reverse=True)
s = sum(p)
poss = [s]
for i in range(n - 1):
	a = s
	for j in range(2, 11):
		if p[i] % j == 0:
			a = min(a, s - p[i] - p[-1] + p[i] // j + p[-1] * j)
			a = min(a, s - p[i] - p[-1] + j + p[-1] * (p[i] // j))
	poss.append(a)
print(min(poss))


n = int(input())
y = [int(k) for k in input().split(' ')]
y = sorted(y)
s = sum(y)
x = len(y)
z = []
z.append(s)
i = x - 2
while i >= 0:
	j = 2
	if y[i] != y[i + 1]:
		while j < y[i + 1]:
			if y[i + 1] % j == 0:
				z.append(s + y[i + 1] / j + y[0] * j - y[0] - y[i + 1])
			j = j + 1
	i = i - 1
print(int(min(z)))


def factors(n):
	fact = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			if n // i == i:
				fact.append(i)
			else:
				fact.append(i)
				fact.append(n // i)
	return fact
n = int(input())
power = list(map(int, input().split()))
total = sum(power)
best = total
mn = min(power)
for a in power:
	if a == mn:
		continue
	curr = total - a - mn
	for x in factors(a):
		best = min(best, curr + a // x + mn * x)
print(best)


TN = 1

def solution():
	n = int(input())
	a = list(map(int, input().split()))
	sm = sum(a)
	mn = min(a)
	s = [sm]
	for i in range(n):
		for j in range(2, int(a[i] ** (1 / 2)) + 1):
			if a[i] % j == 0:
				s.append(sm - a[i] - mn + a[i] // j + mn * j)
	print(min(s))
while TN != 0:
	solution()
	TN -= 1


from sys import stdin
from math import sqrt
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
a = sorted(a)
min_element = a[0]
a_sum = sum(a)
ans = a_sum
for i in range(1, n):
	for j in range(2, a[i] + 1):
		if a[i] % j == 0:
			cur_ans = a_sum - min_element - a[i] + min_element * j + a[i] / j
			ans = min(ans, cur_ans)
print(int(ans))


input()
(*a,) = sorted(map(int, input().split(' ')))
i = len(a) - 1
bestsave = 0
while i > 0:
	x = a[i]
	c = x + a[0]
	for p in range(x - 1, 1, -1):
		if x % p:
			continue
		bestsave = max(bestsave, c - (x // p + a[0] * p))
	i -= 1
print(sum(a) - bestsave)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
z = sum(a)
l = []
l.append(999999999999)
for j in range(2, 101, 1):
	for i in range(n - 1, 0, -1):
		if a[i] % j == 0:
			l.append(z - a[i] - a[0] + a[i] // j + a[0] * j)
			break
print(min(min(l), z))


def factorise(C):
	a = []
	for i in range(2, C // 2 + 1):
		if C % i == 0:
			a.append(i)
	a.append(C)
	return a
N = int(input())
A = list(map(int, input().split(' ')))
min_A = min(A)
A_sum = sum(A)
res = A_sum
for i in range(len(A)):
	num = A[i]
	if num == min_A:
		continue
	factors = factorise(num)
	for f in factors:
		cur_res = A_sum
		cur_res -= num - num // f
		cur_res += (f - 1) * min_A
		res = min(res, cur_res)
print(res)


def f():
	t = int(input())
	n = list(map(int, input().split()))
	l = []
	x = min(n)
	f = sum(n)
	gh = f
	for i in range(t):
		for j in range(2, n[i] // 2 + 1):
			if n[i] % j == 0:
				y = x * j
				a = n[i] // j
				b = y + a
				f1 = f - (n[i] + x)
				f2 = f1 + b
				if gh > f2:
					gh = f2
	print(gh)
f()


n = int(input())
d = list(map(int, input().split()))
sd = sorted(list(set(d)))
m = min(sd)
s = sum(d)

def no(s):
	r = []
	for i in range(1, int(s ** 0.5) + 1):
		if s % i == 0:
			r.append(i)
	r.append(s)
	return r
mm = int(min((s - i - m + i / t + t * m for i in sd for t in no(i))))
print(mm)


n = int(input())
a = [int(s) for s in input().split()]
summa = sum(a)
mini = summa
y = min(a)
y_idx = a.index(y)
z_min = 0
for z in range(len(a)):
	if z != y_idx:
		for x in range(1, 101):
			if a[z] % x == 0:
				k = summa - (a[z] + y) + (a[z] // x + y * x)
				if k < mini:
					mini = k
print(mini)


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	mn = min(a)
	sm = sum(a)
	ans = sm
	for v in a:
		for fact in range(2, v):
			if v % fact == 0:
				rem = v - v // fact
				add = mn * fact - mn
				ans = min(ans, sm + add - rem)
	print(ans)


def read_nums():
	return [int(x) for x in input().split()]

def get_divisors(num):
	res = []
	for i in range(2, num + 1):
		if num % i == 0:
			res.append(i)
	return res

def solve(powers):
	s = sum(powers)
	smallest = min(powers)
	cur_res = s
	for num in set(powers):
		for divisor in get_divisors(num):
			candidate = s - num + num // divisor - smallest + smallest * divisor
			cur_res = min(cur_res, candidate)
	print(cur_res)

def main():
	(n,) = read_nums()
	powers = read_nums()
	solve(powers)

def __starting_point():
	main()
__starting_point()


import math
n = int(input())
li = list(map(int, input().split()))
sumd = sum(li)
li.sort()
ans = sumd
for i in range(n - 1, 0, -1):
	for j in range(2, int(math.sqrt(li[i])) + 1):
		if li[i] % j == 0:
			x = j
			ans = min(ans, sumd - li[i] - li[0] + li[i] // x + li[0] * x)
			x = li[i] // j
			ans = min(ans, sumd - li[i] - li[0] + li[i] // x + li[0] * x)
print(ans)


input()
L = list(map(int, input().split()))
L.sort()
a = L[0]
k = 0
for i in L:
	for j in range(1, int(i ** 0.5 + 1)):
		if i % j == 0 and a + i - (i // j + a * j) > k:
			k = a + i - (i // j + a * j)
print(sum(L) - k)


n = int(input())
l = list(map(int, input().split()))
ans = sum(l)
a = sum(l)
l = list(set(l))
l.sort()
x = max(l)
for i in range(2, x + 1):
	for j in range(len(l) - 1, -1, -1):
		l2 = l.copy()
		if l[j] % i == 0:
			l2[j] = l2[j] // i
			l2[0] *= i
			ans = min(ans, a - l[j] - l[0] + l2[j] + l2[0])
			l2[j] = l[j]
			l2[0] = l[0]
print(ans)


n = int(input())
a = list(map(int, input().split()))
su = sum(a)
a.sort()
mi = a[0]
i = 0
ma = 0
s = list(set(a))
n = len(s)
while i < n:
	j = 2
	while j < s[i]:
		if s[i] % j == 0:
			ans = (j - 1) * (int(s[i] / j) - mi)
			ma = max(ma, ans)
		j += 1
	i += 1
print(su - ma)


n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
minm = min(a)
ans = s
s = s - minm
for i in range(n):
	s = s - a[i]
	for j in range(2, int(a[i] ** 0.5 + 1)):
		if a[i] % j == 0:
			tempans = s + minm * j + a[i] // j
			if ans > tempans:
				ans = tempans
	s = s + a[i]
print(ans)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
ans = sum(a) - max((y + m - y // x - m * x for y in a for x in range(1, y + 1) if y % x == 0))
print(ans)


kam = int(input())
n = list(map(int, input().split()))
jam = sum(n)
lam = []
la = min(n)
n.remove(la)
n.append(la)
ham = n[-1]
for it in n[:-1]:
	x = 2
	s = 0
	kaa = it // 2
	while kaa != 0:
		if it % x == 0:
			sam = it
			gam = it // x
			jh = sam - gam
			f = ham * x - ham
			lam.append(-1 * jh + f)
			x += 1
		else:
			x += 1
			pass
		kaa -= 1
if lam != list():
	hh = min(lam)
	print(min(jam + hh, jam))
else:
	print(jam)


from math import *

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))
N = int(input())
ls = list(map(int, input().split()))
ls.sort()
m = ls[0]
ls = ls[1:]
Sum = sum(ls)
res = []
for i in ls:
	for j in divisors(i):
		res.append(Sum + m * j - i + i // j)
print(min(set(res)))


import sys, math as mt, string, bisect
input = sys.stdin.readline
from collections import deque
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
MAXN = 5 * 10 ** 4 + 1
spf = [0 for i in range(MAXN)]

def sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, mt.ceil(mt.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
sieve()
n = I()
l = L()
x = sum(l)
l.sort(reverse=True)
t = 0
for i in l:
	p = int(i ** 0.5) + 1
	while p > 1:
		if i % p == 0:
			t = max(t, i + l[-1] - p - l[-1] * (i // p), i + l[-1] - i // p - l[-1] * p)
		p -= 1
print(x - t)


n = int(input())
listing = []
dictionary = {}
sum = 0
r = 0
scanner = input()
arr = scanner.split(' ')
new_arr = []
for i in range(len(arr)):
	new_arr.append(int(arr[i]))
	dictionary[new_arr[i]] = 1
	sum += new_arr[i]
new_listing = dictionary.keys()
for x in range(2, 101):
	for i in range(1, 101):
		for j in range(1, 101):
			if i in new_listing and j in new_listing and (i - j != 0) and (i % x == 0):
				r = max(r, i + j - i / x - j * x)
print(int(sum - r))


import sys
n = int(sys.stdin.readline())
a = [int(tmp) for tmp in sys.stdin.readline().split()]
lf = [0] * 101
for ea in a:
	lf[ea] += 1
md = 0
i = 1
j = 100
m = 2
while i * m < j and lf[i] == 0:
	i += 1
while i * m < j and lf[j] == 0:
	j -= 1
while m * i < j:
	while m * i < j:
		if lf[j] == 0:
			j -= 1
			continue
		if j % m == 0:
			md = max(md, j - j // m + i - i * m)
		m += 1
	m = 2
	j -= 1
s = 0
for (p, c) in enumerate(lf):
	s += c * p
print(s - md)


n = int(input())
a = sorted(list(map(int, input().split())))
sm = sum(a)
s = sm
for ind in range(n):
	i = 1
	lst = set()
	while i * i <= a[ind]:
		if a[ind] % i == 0:
			lst.add(i)
			lst.add(a[ind] // i)
		i += 1
	lst = list(lst)
	ln = len(lst)
	for i in range(ln):
		sm = min(sm, s - a[0] - a[ind] + a[ind] // lst[i] + a[0] * lst[i])
print(sm)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
sum = 0
for _ in arr:
	sum = sum + _
div = 0
for i in range(1, n):
	for j in range(1, arr[i] + 1):
		if arr[i] % j == 0:
			div = max(div, arr[0] + arr[i] - arr[i] / j - arr[0] * j)
print(int(sum - div))


def f(a, b):
	min_ans = a + b
	for i in range(1, b // 2 + 1):
		if b % i == 0 and a * i + b // i < min_ans:
			min_ans = a * i + b // i
	return min_ans - a - b
n = int(input())
m = list(map(int, input().split()))
ans = sum(m)
m = set(m)
a = min(m)
l = set()
for i in m:
	l.add(f(a, i))
print(ans + min(l))


from math import *

def factor(x):
	a = []
	for i in range(1, int(x ** 0.5) + 2):
		if x % i == 0:
			a.append(i)
			a.append(x // i)
	return sorted(a)
n = int(input())
a = list(map(int, input().split()))
p0 = sum(a)
p = p0
sa = list(set(a))
for j in range(len(sa)):
	for i in range(len(sa)):
		f = factor(sa[i])
		for k in f:
			if p0 - sa[i] - sa[j] + sa[i] // k + sa[j] * k < p:
				p = p0 - sa[i] - sa[j] + sa[i] // k + sa[j] * k
print(p)


from sys import stdin, stdout
from collections import Counter
n = [int(x) for x in stdin.readline().rstrip().split()][0]
A = [int(x) for x in stdin.readline().rstrip().split()]
arr = list(sorted(set(A)))
min_delta = 0
for i in reversed(range(1, len(arr))):
	for d in range(2, arr[i]):
		if arr[i] % d == 0:
			delta = arr[i] // d + arr[0] * d - (arr[i] + arr[0])
			min_delta = min(min_delta, delta)
ans = sum(A) + min_delta
print(ans)


import sys
import math
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
A.sort()
SUM = sum(A)

def change(i, j):
	NOW = i + j
	xr = math.ceil(math.sqrt(j))
	LIST = []
	for k in range(1, xr + 1):
		if j % k == 0:
			LIST.append(k)
			LIST.append(j // k)
	ANS = float('inf')
	for l in LIST:
		ANS = min(ANS, j // l + i * l)
	return NOW - ANS
ANS = 0
for a in A[1:]:
	ANS = max(ANS, change(A[0], a))
print(SUM - ANS)


a = int(input())
z = [0] * 101
s = 0
m = 101
for i in map(int, input().split()):
	z[i] = 1
	s += i
	m = min(m, i)
k = s
for i in range(1, 101):
	if z[i] == 0:
		continue
	for j in range(1, i + 1):
		if i % j == 0:
			k = min(k, s + m * j - m - i + i // j)
print(k)


import math
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
a.sort()
ans = s
for i in range(n - 1, 0, -1):
	cur = s - a[0] - a[i]
	for j in range(2, int(math.sqrt(a[i]) + 1)):
		if a[i] % j == 0:
			ans = min(ans, cur + a[0] * j + a[i] // j)
print(ans)


from math import sqrt
input()
l = sorted(map(int, input().split()))
total = sum(l)
minimum = total
for i in l:
	for j in range(2, int(sqrt(i)) + 1):
		if i % j == 0:
			minimum = min(total - i + i // j + l[0] * j - l[0], minimum)
print(minimum)


import math
n = int(input())
a = [int(x) for x in input().split()]
sum1 = sum(a)
a.sort()
max_dif = 0
dif = 0
for i in range(n - 1, 0, -1):
	for j in range(2, int(math.sqrt(a[i])) + 1):
		if a[i] % j == 0:
			y = j
			if a[i] - a[i] // y > a[0] * y - a[0]:
				dif = a[i] - a[i] // y - (a[0] * y - a[0])
				if dif > max_dif:
					max_dif = dif
print(sum1 - max_dif)


from math import *
n = int(input())
a = list(map(int, input().split()))
a.sort()
i = 0
j = n - 1
t = False
y = a[0]
s = sum(a) - y
m1 = s + y
while not t and j > i:
	for h in range(2, int(sqrt(a[j])) + 1):
		if a[i] < a[j] // h and a[j] % h == 0:
			m1 = min(m1, s + y * h - a[j] + a[j] // h)
	j -= 1
print(m1)


def main() -> None:
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	sum_list = sum(a)
	score_min = sum_list
	for i in range(1, n):
		for j in range(2, a[i]):
			if a[i] % j == 0:
				score_min = min(score_min, sum_list - a[0] - a[i] + a[0] * j + int(a[i] / j))
	print(score_min)
main()


n = int(input())
a = list(map(int, input().split()))
b = [0] * 101

def fi():
	for i in range(101):
		if b[i] != 0:
			return i
for i in a:
	b[i] += 1

def fact(k):
	b = []
	for i in range(2, k + 1):
		if k % i == 0:
			b.append(i)
	return b
m = fi()
ans = k = sum(a)
for i in range(2, 101):
	if b[i]:
		r = fact(i)
		for j in r:
			ans = min(ans, k - m - i + m * j + i // j)
print(ans)


p = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97)
n = int(input())
a = list(map(int, input().split()))
s = set(a)
x = [i for i in s]
x.sort()
total = 0
for i in a:
	total += i
ans = total
l = len(x) - 1
for i in range(l, 0, -1):
	if x[i] not in p:
		for t in range(1, x[i] // 2 + 1):
			if x[i] % t == 0:
				total2 = total
				total2 -= x[0]
				total2 += x[0] * t
				total2 -= x[i]
				total2 += x[i] // t
				if total2 < ans:
					ans = total2
print(ans)


import copy
import fractions
import itertools
import numbers
import string
import sys

def to_basex(num, x):
	while num > 0:
		yield (num % x)
		num //= x

def from_basex(it, x):
	ret = 0
	p = 1
	for d in it:
		ret += d * p
		p *= x
	return ret

def core():
	n = int(input())
	a = [int(x) for x in input().split()]
	m = min(a)
	s = sum(a)
	ans = s
	for ai in a:
		for d in range(1, ai + 1):
			if ai % d == 0:
				cand = s - ai - m + ai // d + m * d
				ans = min(ans, cand)
	print(ans)
core()


n = int(input())
a = [int(item) for item in input().split()]
a.sort()
s = sum(a)
ans = s
for i in range(len(a)):
	for x in range(2, int(a[i] ** 0.5) + 1):
		if a[i] % x == 0:
			ans = min(ans, s - a[0] - a[i] + a[0] * x + a[i] // x)
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
s = sum(l)
l1 = s
for i in l:
	for j in range(2, i):
		if i % j == 0:
			l1 = min(l1, s - l[-1] + l[-1] * j - i + i // j)
print(l1)


n = int(input())
a = list(sorted(list(map(int, input().split())), reverse=True))
original_sum = sum(a)
minimum_sum = original_sum
min_v = a[-1]
for i in range(n - 1):
	for j in range(2, a[i] - 1):
		if a[i] % j == 0:
			current_sum = original_sum - a[i] - min_v + a[i] // j + min_v * j
			minimum_sum = min(minimum_sum, current_sum)
print(minimum_sum)


n = int(input())
s = list(map(int, input().split()))
su = sum(s)
s = list(set(s))
m = min(s)
s = list(filter(lambda x: x > 2 * m, s))
if len(s) == 0:
	print(su)
	exit()
res = 0
s = list(map(lambda x: x * m, s))
for i in s:
	for j in range(m, int(i ** 0.5) + 1):
		if i % j == 0 and (j % m == 0 or i // j % m == 0):
			res = max(res, i // m + m - i // j - j)
print(-res + su)


n = int(input())
l = [int(j) for j in input().split()]
d = 0
tmin = 0
for i in range(n):
	d = d + l[i]
	if l[tmin] > l[i]:
		tmin = i
minn = l[tmin]
d2 = 0
z = d
for i in range(n):
	r = l[i] // 2
	for j in range(2, r + 1):
		if l[i] % j == 0:
			d2 = d - l[i] + l[i] // j - minn + minn * j
			if d2 < d and d2 < z:
				z = d2
print(z)


n = int(input())
arr = list(map(int, input().strip().split()))
x = sum(arr)
arr = sorted(arr)
ans = [x]
for i in range(n - 1, -1, -1):
	for j in range(1, arr[i] + 1):
		if arr[i] % j == 0:
			if arr[i] + arr[0] > arr[i] // j + arr[0] * j:
				ans.append(x - arr[i] - arr[0] + arr[0] * j + arr[i] // j)
print(min(ans))


n = int(input())
A = list(map(int, input().split()))
A.sort()
suma = 0
for i in range(n):
	suma += A[i]
mini = suma
for i in range(1, n):
	x = 1
	temp = 10000000000
	while x <= A[i]:
		if A[i] % x == 0:
			temp = min(temp, A[0] * x - A[0] + (A[i] // x - A[i]))
		x += 1
	if suma + temp < mini:
		mini = suma + temp
print(mini)


class CodeforcesTask1113BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.machines = []

	def read_input(self):
		self.n = int(input())
		self.machines = [int(x) for x in input().split(' ')]

	def process_task(self):
		tc = list(set(self.machines))
		ss = sum(self.machines)
		if len(tc) > 1:
			z = [[] for x in range(100)]
			for x in range(1, 101):
				for y in range(1, x + 1):
					if not x % y:
						z[x - 1].append(y)
			mn = ss
			for a in tc:
				for b in tc:
					if a != b:
						base = a + b
						for d in z[a - 1]:
							if a // d + b * d < base:
								mn = min(mn, ss - base + a // d + b * d)
			self.result = str(mn)
		else:
			self.result = str(ss)

	def get_result(self):
		return self.result
Solution = CodeforcesTask1113BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
arr = sorted(list(map(int, input().split())))
t = sum(arr)
mm = arr[0]
ans = t
for i in arr:
	for j in range(1, i + 1):
		if i % j == 0:
			curr = t - i + i // j - mm + mm * j
			ans = min(ans, curr)
print(ans)


n = int(input())
lst = list(map(int, input().split()))
(mi, res, k) = (min(lst), sum(lst), 0)
result = res
for (i, x) in enumerate(lst):
	if x != mi:
		a = int(x ** 0.5)
		item = mi + x
		for i in range(1, a + 1):
			if x % i == 0:
				b = x // i + mi * i
				if b - item < k:
					result = res - item + b
					k = b - item
print(result)


def factors(x):
	result = []
	i = 1
	while i * i <= x:
		if x % i == 0:
			result.append(i)
			if x / i != i:
				result.append(int(x / i))
		i += 1
	return result
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
x = min(a)
luv = []
for i in range(n):
	se = []
	y = a[i]
	li = factors(y)
	for j in range(len(li)):
		a1 = x * li[j] + y // li[j]
		se.append(x + y - a1)
	luv.append(max(se))
print(s - max(luv))


f = lambda : list(map(int, input().split()))
n = int(input())
a = f()
(m, s) = (min(a), sum(a))
ans = sum(a)
for x in a:
	for d in range(1, x + 1):
		if x % d == 0:
			cur = s - m - x + m * d + x // d
			ans = min(ans, cur)
print(ans)


input()
lis = [*map(int, input().split())]
k = min(lis)
l = []
for y in lis:
	for i in range(1, y + 1):
		if y % i == 0:
			l.append(k + y - y // i - k * i)
print(sum(lis) - max(l))


def maksik(a, b):
	res = 100000
	i = 1
	while i ** 2 <= a:
		if a % i == 0:
			res = min(res, a // i + b * i)
		i = i + 1
	j = 1
	while j ** 2 <= b:
		if b % j == 0:
			res = min(res, b // j + a * j)
		j = j + 1
	return int(res - a - b)
n = int(input())
powers = list(map(int, input().split()))
przynaleznosc = [0] * 101
for i in powers:
	przynaleznosc[i] = 1
wynik = 0
for t in range(1, 101):
	for s in range(1, 101):
		if przynaleznosc[t] == 1 and przynaleznosc[s] == 1 and (t != s):
			wynik = min(wynik, maksik(t, s))
print(sum(powers) + wynik)


import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mm = 1000000007
t = 1
for it in range(t):
	n = nu()
	a = li()
	a.sort()
	s = sum(a)
	cv = s
	for i in range(n - 1, 0, -1):
		zp = a[i]
		cc = 1
		while cc <= ma.sqrt(zp):
			if zp % cc == 0:
				if zp // cc == cc:
					xp = s - (zp - zp // cc) + (a[0] * cc - a[0])
					if xp < cv:
						cv = xp
				else:
					xp = s - (zp - zp // cc) + (a[0] * cc - a[0])
					if xp < cv:
						cv = xp
					gg = cc
					cc = zp // cc
					xp = s - (zp - zp // cc) + (a[0] * cc - a[0])
					if xp < cv:
						cv = xp
					cc = gg
			cc += 1
	print(cv)


import math
n = list(map(int, input().split()))
cl = sorted(list(map(int, input().split())))[::-1]
sm = sum(cl)
mn = sm
for x in cl:
	for y in range(2, int(math.sqrt(x)) + 1):
		if x % y == 0:
			res1 = sm - x - cl[-1] + cl[-1] * y + x // y
			res2 = sm - x - cl[-1] + cl[-1] * x // y + y
			res = min(res1, res2)
			if res < mn:
				mn = res
print(mn)


def carpan(n):
	lst = []
	sq = n ** 0.5 + 1
	for i in range(2, int(sq) + 1):
		if n % i == 0:
			lst.append(i)
	return lst
n = int(input())
lst = list(map(int, input().split()))
lst = sorted(lst, reverse=True)
mn = lst[-1]
total = sum(lst)
large = 0
for i in lst:
	mx = i
	lst1 = carpan(mx)
	for j in lst1:
		if mx + mn - (mx / j + mn * j) > large:
			large = mx + mn - (mx / j + mn * j)
print(int(total - large))


def inpl():
	return list(map(int, input().split()))
N = int(input())
A = inpl()
A.sort()
ma = A[0]
ans = 0
for b in A[1:]:
	for x in range(1, b // 2 + 1):
		if b % x:
			continue
		ans = max(ans, ma + b - ma * x - b // x)
print(sum(A) - ans)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))

def fac(x):
	a = []
	for i in range(1, int(x ** 0.5) + 2):
		if x % i == 0:
			a.append(i)
			if i ** 2 != x:
				a.append(x // i)
	return a
f = [0]
(n,) = I()
l = I()
s = sum(l)
l = list(set(l))
f = [0]
ans = s
for i in range(1, 101):
	f.append(fac(i))
for i in l:
	for j in l:
		if i >= j:
			continue
		for k in f[j]:
			ans = min(ans, s - i - j + i * k + j // k)
print(ans)


n = int(input())
i = 0
mini = 5 * 1000000 + 2
mintabl = 5 * 1000000 + 1
sum = 0
inpt = input()
machines = [int(mach) for mach in inpt.rsplit(' ')]
for element in machines:
	sum += element
	mini = min(mini, element)
for machine in machines:
	for x in range(1, 100 // 2 + 1):
		if machine % x == 0:
			mintabl = min(mintabl, sum - machine + machine // x - mini + mini * x)
print(mintabl)


from math import sqrt

def ret(n):
	ans = set()
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			ans.add(i)
			ans.add(n // i)
	return ans
n = int(input())
l = list(map(int, input().split()))
mini = sum(l)
z1 = sum(l)
l.sort()
z = ret(l[0])
for j in z:
	k = z1 - (l[0] + l[1])
	k += l[0] // j + l[1] * j
	if k >= 0:
		if k < mini:
			mini = k
for i in range(1, n):
	z = ret(l[i])
	for j in z:
		k = z1 - (l[0] + l[i])
		if k >= 0:
			k += l[0] * j + l[i] // j
			if k < mini:
				mini = k
print(mini)


n = int(input())
arr_str = input().split()
arr = [int(x) for x in arr_str]
min_el = arr[0]
s = 0
for x in arr:
	s += x
	if x < min_el:
		min_el = x
diff = 0
for x in arr:
	if x == min_el:
		continue
	for y in range(2, x // 2 + 1):
		if x % y == 0:
			new_x = x // y
			new_min = min_el * y
			new_diff = x + min_el - new_x - new_min
			if new_diff > diff:
				diff = new_diff
print(s - diff)


def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return factors

def factor(n):
	super = [1]
	for i in prime_factors(n):
		super.extend([j * i for j in super])
	return list(sorted(set(super)))
num = int(input())
list_1 = [int(i) for i in input().split()]
list_2 = list(sorted(set(list_1)))
length = len(list_2)
maximum = 0
for i in range(1, length):
	minimum = list_2[0]
	_factor = factor(list_2[i])
	for j in _factor:
		diff = minimum + list_2[i] - minimum * j - list_2[i] // j
		maximum = max(maximum, diff)
print(sum(list_1) - maximum)


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
val = sum(arr)
temp = min(arr)
ans = [val]
for i in range(n):
	now = arr[i]
	factor = set()
	for j in range(1, int(now ** 0.5) + 1):
		if now % j == 0:
			factor.add(j)
			factor.add(now // j)
	for j in factor:
		res = val + (1 - j) * (now // j) + (j - 1) * temp
		ans.append(res)
print(min(ans))


for _ in range(1):
	input()
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	m = 0
	for i in a:
		for j in range(i - 1, 1, -1):
			if i % j == 0:
				if i // j - i + a[-1] * j - a[-1] < m:
					m = i // j - i + a[-1] * j - a[-1]
	print(sum(a) + m)


(n, ls) = (int(input()), sorted(list(map(int, input().split()))))
(cv, best) = (sum(ls), 0)
for i in range(2, 50):
	pi = ls[0] * (i - 1)
	for l in reversed(ls):
		if l % i == 0:
			mi = l - l // i
			break
	else:
		continue
	if pi - mi < best:
		best = pi - mi
print(cv + best)


import math
n = int(input())
a = input().split()
a = [int(i) for i in a]
m = a[0]
ans = 0
mi = 0
for i in a:
	if i < m:
		m = i
	ans += i
for i in a:
	for j in range(2, i):
		if i % j == 0:
			if (m - j) * (i / j - 1) < mi:
				mi = int((m - j) * (i / j - 1))
			if (m - i / j) * (j - 1) < mi:
				mi = int((m - i / j) * (j - 1))
print(ans + mi)


n = int(input())
x = list(map(int, input().split()))
x.sort()
min = min(x)
sum = sum(x)
s = sum
for a in x:
	for i in range(2, a):
		if a % i == 0:
			t = int(s - min - a + min * i + a / i)
			if t < sum:
				sum = t
print(sum)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
min1 = a[0]
p = 0
for i in a:
	for j in range(1, int(i ** 0.5 + 1)):
		if i % j == 0 and min1 + i - min1 * j - i // j > p:
			p = min1 + i - min1 * j - i // j
print(sum(a) - p)


import sys, math, io, os, time, itertools, collections
mod = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(10000)
i = sys.stdin.readline
p = sys.stdout.write
global start, end

def div(n):
	l = deque()
	p = int(math.sqrt(n))
	for k in range(p, 0, -1):
		if n % k == 0:
			if n // k == k:
				l.append(k)
			else:
				l.append(n // k)
				l.appendleft(k)
	return l

def main():
	n = int(i())
	a = [int(k) for k in i().split()]
	small = sum(a)
	s = sum(a)
	aJ = min(a)
	a.remove(aJ)
	for el in a:
		l = div(el)
		temp = mod
		for d in l:
			temp2 = s + (d - 1) * (aJ - el // d)
			temp = min(temp, temp2)
		small = min(small, temp)
	p(str(small) + '\n')
t = 1
start = time.perf_counter()
for _ in range(t):
	main()
end = time.perf_counter()


n = int(input())
l = list(map(int, input().split()))
v = sum(l)
d = set(l)
so = sorted(l)
val = 0
for x in d:
	y = so[0] + x
	for j in range(2, 101):
		if x % j == 0:
			mi = y - so[0] * j - x // j
			val = max(mi, val)
print(v - val)


n = int(input())
arr = list(map(int, input().split()))
(sumi, mini, curr) = (sum(arr), sum(arr), 0)
arr = set(arr)
arr = list(arr)
arr = sorted(arr)
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
for i in range(len(arr) - 1, 0, -1):
	if arr[i] in primes:
		if 1 + arr[0] * arr[i] < arr[0] + arr[i]:
			curr = sumi - arr[0] - arr[i] + 1 + arr[0] * arr[i]
			if curr < mini:
				mini = curr
	else:
		for j in range(2, arr[i]):
			if j > arr[i]:
				break
			if arr[i] % j == 0:
				if arr[i] // j + arr[0] * j < arr[i] + arr[0]:
					curr = sumi - arr[0] - arr[i] + arr[i] // j + arr[0] * j
					if curr < mini:
						mini = curr
print(mini)


from math import ceil, sqrt, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())
n = ii()
a = li()
x = min(a)
s = sum(a)
b = []
b.append(s)
for j in a:
	if j == x:
		continue
	s3 = s - (x + j)
	s1 = x + j
	for i in range(2, int(sqrt(j)) + 1):
		if j % i == 0:
			s2 = x * i + j // i
			s1 = min(s1, s2)
	s3 += s1
	b.append(s3)
print(min(b))


list_int_input = lambda inp: list(map(int, inp.split()))
int_input = lambda inp: int(inp)
string_to_list_input = lambda inp: list(inp)
n = int(input())
lst = list(map(int, input().split()))
minn = min(lst)
summ = sum(lst)
sum1 = summ
val = -1
for i in range(50, 1, -1):
	for j in lst:
		if j % i == 0:
			val = i
			sum1 = min(summ - minn - j + int(j / i) + i * minn, sum1)
print(sum1)


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
ans = s
for i in range(2, 101):
	for j in range(n - 1, 0, -1):
		if a[j] % i == 0:
			t = s - a[j] - a[0] + i * a[0] + a[j] // i
			if t < ans:
				ans = t
print(ans)


from collections import defaultdict
import math
xx = defaultdict(int)
i = int(input())
min = 101
max = 1
sum = 0

def getDivisors(n, div):
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				div.append(i)
			else:
				div.append(i)
				div.append(n / i)
		i = i + 1
a = list(map(int, input().split()))
for x in a:
	xx[x] = x
	sum += x
pm = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
for x in xx:
	if min > x:
		min = x
mintmp = 0
for x in xx:
	div = []
	getDivisors(x, div)
	for y in div:
		tmp = int(x / y + min * y - x - min)
		if tmp < mintmp:
			mintmp = tmp
sum += mintmp
print(sum)


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict, deque, Counter, OrderedDict
from copy import deepcopy
import threading

def main():
	n = int(input())
	a = [*map(int, input().split())]
	a.sort()
	ans = sum(a)
	val = sum(a)
	for i in range(n):
		k = a[i]
		z = []
		for j in range(2, k):
			if k % j == 0:
				z.append(j)
		for x in z:
			ans = min(ans, val - (k - k // x) + (a[0] * x - a[0]))
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
sm = sum(a)
ans = sm
for i in range(n):
	s = sm
	x = a[0]
	y = a[i]
	for j in range(1, y + 1):
		if y % j == 0:
			q = x * j
			w = y // j
			m = s - x - y + q + w
			if m < ans:
				ans = m
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
total_output = sum(a)
a = sorted(list(set(a)))
reduction = 0
for i in range(0, len(a) - 1):
	for j in range(i, len(a)):
		for k in range(1, 100):
			if a[j] % k == 0:
				reduction = max(reduction, a[j] + a[i] - (a[j] / k + a[i] * k))
print(int(total_output - reduction))


def findFactor(num):
	ans = [1, num]
	for i in range(2, 11):
		if num % i == 0:
			ans.append(i)
			ans.append(num // i)
	return ans
n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
m = arr[n - 1]
result = []
for x in arr:
	ans = findFactor(x)
	diff = []
	for f in ans:
		diff.append(x - x // f + (m - f * m))
	temp = max(diff)
	result.append(temp)
print(sum(arr) - max(result))


def g():
	t = int(input())
	l = list(map(int, input().split()))
	s = list(set(l))
	length = len(s)
	s.sort(reverse=True)
	mx = 0
	for i in range(length - 1):
		for j in range(s[i], 0, -1):
			if s[i] % j == 0:
				b = s[i] - s[i] // j
				c = s[length - 1] * j - s[length - 1]
				if b - c >= mx:
					mx = b - c
	print(sum(l) - mx)
g()


n = int(input())
A = list(map(int, input().split()))
M = min(A)
ahaha = 0
fl = 0
su = 0
for q in A:
	su += q
	if q != M:
		for d in range(2, int(q ** 0.5) + 1):
			if q % d == 0:
				ahaha = max(ahaha, -(-M - q + M * d + q // d))
				ahaha = max(ahaha, -(-M - q + M * (q // d) + q // (q // d)))
print(su - ahaha)


n = int(input())
a = [int(c) for c in input().split()]
mn = min(a)
sm = sum(a)
ans = sm
a.sort()
for i in range(1, 100):
	for j in range(1, n):
		if a[j] % i == 0:
			new = a[j] // i + mn * i
			if a[j] + mn > new:
				ans = min(ans, new + sm - a[j] - mn)
print(ans)


import math
n = int(input())
a = list(map(int, input().split()))
acc = sum(a)
ans = acc
min_element = min(a)
for i in range(n):
	for j in range(2, int(math.sqrt(a[i])) + 1):
		if a[i] % j == 0:
			ans = min(ans, acc - min_element - a[i] + a[i] // j + min_element * j)
			if a[i] // j != j:
				c = a[i] // j
				ans = min(ans, acc - min_element - a[i] + a[i] // c + min_element * c)
print(ans)


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
best = s
m = min(a)
for i in range(n):
	for j in range(1, a[i] + 1):
		if a[i] % j:
			continue
		best = min(best, s - a[i] - m + a[i] // j + m * j)
print(best)


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = float('inf')
s = sum(a)
for d in range(1, 11):
	for c in range(n - 1, -1, -1):
		if a[c] % d == 0:
			ans = min(s - a[c] + a[c] // d - a[0] + a[0] * d, ans)
			break
print(ans)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
k = sum(a[1:])
l = a[0]
mini = 10000000000
for i in range(1, len(a)):
	c = []
	for j in range(1, a[i] + 1):
		if a[i] % j == 0:
			c.append(j)
	for j in range(len(c)):
		s = k - a[i] + a[0] * c[j] + a[i] // c[j]
		if s < mini:
			mini = s
print(mini)


n = int(input())
l = list(map(int, input().split()))
cnt = sum(l)
ans = []
ans.append(cnt)
l = set(l)
l = list(l)
for i in range(len(l)):
	tmp = []
	for k in range(1, l[i] + 1):
		if l[i] % k == 0:
			tmp.append(k)
	for k in range(len(tmp)):
		for j in range(len(l)):
			if i == j:
				continue
			ans.append(cnt - l[i] - l[j] + l[i] // tmp[k] + l[j] * tmp[k])
ans.sort()
print(ans[0])


import math
n = int(input())
a = [int(i) for i in input().split()]
s0 = 0
a_min = 101
k = 0
for i in range(n):
	s0 += a[i]
	if a[i] < a_min:
		a_min = a[i]
s = s0
s_b = s0
a_l = a_min
for i in range(n):
	for x in range(1, int(math.sqrt(a[i])) + 1):
		if a[i] != a_min:
			s -= a[i] + a_min
			a[i] /= x
			a_min *= x
			s += a[i] + a_min
			if a[i] == int(a[i]) and s < s_b:
				s_b = s
			s = s0
			a[i] *= x
			a_min = a_l
print(int(s_b))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	result = s
	nums = {x for x in a}
	for x in nums:
		for y in nums:
			if x != y:
				for div in range(2, x):
					if x % div == 0:
						tmp = s - x - y
						result = min(result, tmp + x // div + y * div)
	print(result)
main()


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]

def solve(n):
	d = []
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			if n // i == i:
				d.append(i)
			else:
				d += [i, n // i]
	return d
n = INT()
arr = LIST()
if len(set(arr)) == 1:
	print(sum(arr))
	exit(0)
sm = sum(arr)
res = sm
mn = min(arr)
indx = arr.index(mn)
for i in range(n):
	if indx == i:
		continue
	else:
		x = solve(arr[i])
		for j in x:
			cur = sm - mn - arr[i]
			cur += arr[i] // j
			cur += mn * j
			res = min(res, cur)
print(res)


from math import ceil
n = int(input())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
min_a = a[0]
max_diff = 0
for i in range(n - 1, 0, -1):
	min_s = min_a + a[i]
	for j in range(2, a[i]):
		if a[i] % j == 0:
			if min_s - a[i] // j - min_a * j > max_diff:
				max_diff = min_s - a[i] // j - min_a * j
print(s - max_diff)


from sys import stdin
from functools import reduce
from itertools import count, islice
from math import sqrt

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(2, int(n ** 0.5) + 1) if n % i == 0))))

def isPrime(n):
	return n > 1 and all((n % i for i in islice(count(2), int(sqrt(n) - 1))))
n = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
s = sorted(list(set(arr)), reverse=True)
gst = []
for i in range(len(s) - 1):
	if isPrime(s[i]) == True:
		pass
	else:
		ans = factors(s[i])
		ele = s[i]
		test = []
		total = sum(arr) - ele - min(s)
		for item in ans:
			test.append(ele // item + min(s) * item)
		total += min(test)
		gst.append(total)
if len(gst) > 0:
	print(min(min(gst), sum(arr)))
else:
	print(sum(arr))


n = int(input())
arr = list(map(int, input().strip().split()))
values = set()
s = 0
for elem in arr:
	values.add(elem)
	s += elem
values = list(values)
running_sum = s
for i in range(len(values)):
	for j in range(i + 1, len(values)):
		(a, b) = (values[i], values[j])
		if a < b:
			(a, b) = (b, a)
		for k in range(1, a + 1):
			if a % k:
				continue
			running_sum = min(s - a - b + a // k + b * k, running_sum)
print(running_sum)


cnt = lambda s, i: s.count(i)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
fac = set()
n = ii()
l = il()
sm = sum(l)
l = list(set(l))
for i in l:
	for j in range(1, int(i ** 0.5) + 1):
		if i % j == 0:
			fac.add(j)
			if j ** 2 != i:
				fac.add(i // j)
fac = list(fac)
mn = min(l)
mnp = 0
for i in l:
	for j in fac:
		if i % j == 0:
			mnp = min(mnp, -mn - i + mn * j + i // j)
print(sm + mnp)


import sys
import math

def getAndParseInt(num=1):
	string = sys.stdin.readline().strip()
	if num == 1:
		return int(string)
	else:
		return [int(part) for part in string.split()]

def getAndParseString(num=1, delim=' '):
	string = sys.stdin.readline().strip()
	if num == 1:
		return string
	else:
		return [part for part in string.split(delim)]
n = getAndParseInt()
nums = getAndParseInt(2)
if n == 1:
	print(nums[0])
else:
	nums.sort()
	total = sum(nums) - nums[0]
	smallest = nums[0]
	lowest_poss = sum(nums)
	for i in reversed(range(1, n)):
		sum_red = total - nums[i]
		for j in range(2, nums[i] - 1):
			if nums[i] % j == 0:
				temp_sum = sum_red + nums[i] // j + j * smallest
				if temp_sum < lowest_poss:
					lowest_poss = temp_sum
	print(lowest_poss)


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)
n = int(input())
a = sorted(list(map(int, input().split())))
mini = sum(a)
s = sum(a)
x = min(a)
for i in range(len(a) - 1, -1, -1):
	fac = factors(a[i])
	for j in range(0, len(fac)):
		c = s - a[i] - x
		c += a[i] // fac[j] + x * fac[j]
		mini = min(mini, c)
print(mini)


n = int(input())
m = list(map(int, input().split()))
su = sum(m)
mi = min(m)
from math import sqrt
cand = []
for j in m:
	if j != mi:
		divs = set()
		for i in range(1, int(sqrt(j)) + 1):
			if j % i == 0:
				divs.add(j // i)
				divs.add(i)
		for i in divs:
			tmp = su - j + j // i - mi + mi * i
			cand.append(tmp)
if cand:
	print(min(cand))
else:
	print(su)


import sys
n = int(sys.stdin.readline())
inp = sys.stdin.readline()[:-1].split(' ')
nums = {}
fullSum = 0
for num in inp:
	fullSum = fullSum + int(num)
	nums[num] = True
numsArr = [int(num) for num in nums]
numsArr.sort()
firstNum = numsArr[0]
maxRaz = 0
for i in range(len(numsArr) - 1, (len(numsArr) - 2) // 2, -1):
	mainNum = numsArr[i]
	for i2 in range(2, mainNum // 2 + 1):
		if mainNum % i2 == 0:
			tmpMax = mainNum + firstNum
			ch1 = mainNum // i2
			ch2 = firstNum * i2
			tmpMax = tmpMax - (ch1 + ch2)
			if tmpMax > maxRaz:
				maxRaz = tmpMax
print(fullSum - maxRaz)


from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def sol():
	am = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	mS = s
	m = min(arr)
	for i in range(am):
		facs = list(factors(arr[i]))
		for g in range(len(facs)):
			mS = min(mS, s - m - arr[i] + m * facs[g] + arr[i] // facs[g])
	print(mS)
sol()


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
p = sum(arr)
a = []
d = {}
for i in range(1, 101):
	d[i] = 0
for i in arr:
	d[i] += 1
for i in range(1, 101):
	for j in range(1, 101):
		if j % i == 0:
			for k in range(1, 101):
				a.append((j, k, k + j - j // i - k * i))
m = -100000000
for i in a:
	if i[0] == i[1]:
		if d[i[0]] >= 2:
			m = max(m, i[2])
	elif d[i[0]] != 0 and d[i[1]] != 0:
		m = max(m, i[2])
print(p - m)


import math
input()
powers = sorted(map(int, input().split()), reverse=True)
total = sum(powers)
minimum = total
for pwr in powers:
	for i in range(2, int(math.sqrt(pwr)) + 1):
		if pwr % i == 0:
			minimum = min(total - pwr + pwr // i + powers[-1] * i - powers[-1], minimum)
print(minimum)


import math

def alld(x):
	b = []
	for i in range(2, x // 2 + 5):
		if x % i == 0:
			b.append(i)
	b.append(x)
	return b
n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
mn = min(a)
minn = sum(a)
su = 0
ku = 0
x = 0
s = 0
rz = 0
for i in range(n):
	if a[i] != mn:
		c = alld(a[i])
		for j in c:
			stc = mn + a[i]
			tc = mn * j + a[i] // j
			if stc - tc > rz:
				rz = stc - tc
print(sum(a) - rz)
exit()
av = su // ku
s = sum(a)
for i in range(n):
	if a[i] != mn and a[i] % av == 0:
		tc = mn + a[i]
		izm = mn * av + a[i] // av
		if izm < tc and s + izm - tc < minn:
			minn = s + izm - tc
print(minn)


n = int(input())
A = [int(x) for x in input().split()]
m = min(A)
s = sum(A)
result = s
for i in range(len(A)):
	if A[i] != m:
		for x in range(1, A[i]):
			if A[i] % x == 0:
				result = min([result, s + m * (x - 1) - A[i] + A[i] // x])
print(result)


import math
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in l:
	ans += i
mn = -100000
mni = -1
for i in range(1, n):
	for j in range(2, math.ceil(math.sqrt(l[i])) + 1):
		if l[i] % j == 0:
			d = -l[i] // j - l[0] * j + l[i] + l[0]
			if mn < d:
				mn = d
				mx = l[i] // j + l[0] * j
				mni = i
if mni != -1:
	alt = ans - l[0] - l[mni] + mx
else:
	print(ans)
	exit()
if alt > ans:
	print(ans)
else:
	print(alt)


n = int(input())
a = list(map(int, input().split()))
a.sort()
sm = sum(a)
s = sm
for i in range(1, n):
	for j in range(2, 50):
		if a[i] % j == 0:
			s = min(s, sm - a[i] + a[i] // j - a[0] + a[0] * j)
print(s)


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5:
	from math import gcd
else:
	from fractions import gcd
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def round(x):
	return int((x * 2 + 1) // 2)

def fermat(x, y, MOD):
	return x * pow(y, MOD - 2, MOD) % MOD

def lcm(x, y):
	return x * y // gcd(x, y)

def lcm_list(nums):
	return reduce(lcm, nums, 1)

def gcd_list(nums):
	return reduce(gcd, nums, nums[0])

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
sm = sum(A)
mn_A = min(A)
A = set(A)
ans = sm
for x in range(2, max(A) + 1):
	for v in A:
		if v % x == 0:
			dec = v - v // x
			ans = min(ans, sm - dec + mn_A * x - mn_A)
print(ans)


import sys
from functools import reduce
from math import sqrt, floor

def eprint(*args, **kwargs):
	if not __debug__:
		print(*args, file=sys.stderr, **kwargs)
eprint('Local')
for t in range(int(input()) if not __debug__ else 1):
	n = int(input())
	arr = list(map(int, input().split()))
	min_idx = 0
	for i in range(n):
		if arr[i] < arr[min_idx]:
			min_idx = i
	total_power = reduce(lambda x, y: x + y, arr)
	min_power = total_power
	for ai in arr:
		if ai == arr[min_idx]:
			continue
		x = ai
		while x > 1:
			if ai % x != 0:
				x -= 1
				continue
			cur_power = total_power
			cur_power -= arr[min_idx]
			cur_power -= ai
			cur_power += ai // x
			cur_power += x * arr[min_idx]
			if cur_power < min_power:
				min_power = cur_power
			x -= 1
	print(min_power)


n = int(input())
a = [int(t) for t in input().split(' ')]
min_number = min(a)
defaultpower = sum(a)
minpower = defaultpower
for m in range(2, max(a) + 1):
	maxi = -1
	for i in range(n):
		if a[i] % m == 0 and (maxi == -1 or a[i] > a[maxi]):
			maxi = i
	if maxi == -1:
		continue
	power = defaultpower - min_number - a[maxi] + min_number * m + a[maxi] // m
	minpower = min(power, minpower)
print(minpower)


import math

def factors(n):
	result = []
	for i in range(1, n + 1):
		if n % i == 0:
			result.append(i)
	return result
a = input()
b = input()
content = [a]
content.append(b.split())
number = int(content[0])
powers = content[1]
for i in range(number):
	powers[i] = int(powers[i])
newpowers = []
minloss = 0
for i in powers:
	if i not in newpowers:
		newpowers.append(int(i))
for i in newpowers:
	for j in newpowers:
		if j != i and i < j:
			for k in factors(j):
				if j / k + i * k < j + i and j + i - j / k - i * k > minloss:
					minloss = j + i - j / k - i * k
for i in newpowers:
	counter = 0
	for j in powers:
		if j == i:
			counter += 1
	if counter > 1:
		for k in factors(i):
			if i * k + i / k < 2 * i and 2 * i - k * i - i / k > minloss:
				minloss = 2 * i - k * i - i / k
if minloss == 0:
	print(int(sum(powers)))
else:
	print(int(sum(powers) - minloss))


def cin():
	return map(int, input().split())
import collections
n = int(input())
a = list(cin())
a.sort(reverse=True)
ans = total = sum(a)
for i in range(n - 1):
	for j in range(2, int(a[i] ** 0.5) + 1):
		if not a[i] % j:
			ans = min(ans, total - a[i] + a[i] // j - a[-1] + a[-1] * j)
print(ans)


def f(a):
	i = 2
	b = []
	while i * i <= a:
		if a % i == 0:
			b.append(i)
		i += 1
	return b
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = sum(a)
ans2 = ans + 0
for i in range(n - 1, -1, -1):
	d = f(a[i])
	for j in d:
		if ans - a[0] - a[i] + a[0] * j + a[i] // j < ans2:
			ans2 = ans - a[0] - a[i] + a[0] * j + a[i] // j
print(ans2)