def gcd(a,b):
    result = 0
    for i in range(2, min(a,b)+1):
        if (a % i == 0 and b % i == 0):
            result = i
    return result

def solution():
    a = int(input())
    b = list(map(int, input().split()))
    c = []
    for i in b:
        for j in range(2, i+1):
            while (i % j == 0):
                c.append(j)
                i /= j

    c = sorted(c)

    result = 0
    for i in range(2, len(c)-1):
        result += gcd(c[i], c[i+1])
    result += gcd(c[-1], c[-2])


    print(result)
    return 0


if __name__ == '__main__':
    solution()