from collections import Counter
from math import gcd

input()
nums = list(sorted(map(int, input().split(' ')), reverse=True))

running_sum = 0

left = nums[0]
right = nums[0]
del nums[0]

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
    nums.remove(max_n)
    if l:
        left = max_n
    else:
        right = max_n

print(running_sum)

