mod = 998244353 NN = 10 ** 5 def main(): import sys input = sys.stdin.readline div = [[] for _ in range(NN + 1)] for d in range(1, NN + 1): for x in range(1, NN + 1): if d * x > NN: break div[d * x].append(d) N = int(input()) A = list(map(int, input().split())) A.sort() ans = 0 seen = [10 ** 17] * (NN + 1) a = A[0] for d in div[a]: seen[d] = min(seen[d], a // d) for a in A[1:]: mi = 10 ** 17 for d in div[a][::-1]: mi = min(mi, seen[d]) ans += a * mi for d in div[a]: seen[d] = min(seen[d], a // d) print(ans) if __name__ == '__main__': main()