from math import gcd
from itertools import combinations_with_replacement, permutations

N=int(input())
A=list(map(int,input().split()))
p = [2,3,4,5,6,7,8,9,10,12,14,15,16,18,20]


def f(p, counts):
    res1 = 0
    for x in range(1,21):
        if counts[x]:
            res1 += (counts[x] - 1) * x
    px = [a for a in range(1,21) if counts[a]]
    best = 0
    for p in permutations(px):
        res2 = res1
        for x, y in zip(p, p[1:]):
            res2 += gcd(x, y)
        best = max(best, res2)
    return best

def calculate(A):
    counts = [0 for _ in range(21)]
    for a in A:
        counts[a] += 1

    return f(p, counts)

print(calculate(A))