import fileinput as fi
from collections import Counter
IN = fi.input()

def INT():
    return int(IN.readline())

def INTS():
    return tuple(int(num) for num in IN.readline().split())

def help(a, b):
    a, b = sorted((a, b))
    while a != 0:
        a, b = b % a, a
    return b
def gcd(a, bs):
    if not bs:
        return []
    mx = max(help(a, b) for b in bs)
    return [b for b in bs if help(a, b) == mx]




x = INT()
y = INTS()

dic = Counter(y)
se = set(y)

res = 0
for i in dic:
    res += (dic[i] - 1) * i 

new=min(se)
se.remove(new)
mn = new
while se:
    
    new = min(gcd(mn, se))
    res += help(mn, new)
    se.remove(new)
    mn = new

print(res)
