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()))
    b = sorted(b)

    result = 0
    for i in range(0, len(b)-1):
        temp = 0
        for j in range(i + 1, len(b)):
            temp = max(temp, gcd(b[i], b[j]))
        result += temp



    print(result)
    return 0


if __name__ == '__main__':
    solution()