from math import gcd
from collections import Counter

input()
counts = Counter(map(int, input().split(' ')))
nums = list(sorted(counts))

running_sum = 0

left = nums[-1]
right = nums[-1]
del nums[-1]

# res = [left]

while nums:
    max_gcd = 0
    max_n = None
    l = False
    for n in nums:
        gcdl = gcd(left, n)
        gcdr = gcd(right, n)
        
        if gcdl > max_gcd:
            max_gcd = gcdl
            l = True
            max_n = n
        if gcdr > max_gcd:
            max_gcd = gcdr
            l = False
            max_n = n

    running_sum += max_gcd
    if l:
        left = max_n
        # res.insert(0, max_n)
    else:
        right = max_n
        # res.append(max_n)
    counts[max_n] -= 1
    if not counts[max_n]:
        del counts[max_n]
        nums.remove(max_n)

    # print(running_sum, left, right)

print(running_sum)
# print(res)

