mod = 998244353 NN = 10 ** 5 def main(): import sys from heapq import heappush, heappop from collections import Counter, deque from math import gcd 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())) C = Counter(A) ans = 0 mi = [deque() for _ in range(NN + 1)] A_sorted = sorted(list(set(A))) for i, a in enumerate(A_sorted): ans += a * (C[a] - 1) if i: for d in div[a]: mi[d].append(a) if len(A_sorted) == 1: print(ans) exit() pq = [] seen = [0] * (NN + 1) a0 = A_sorted[0] seen[a0] = 1 for d in div[a0]: if mi[d]: a = mi[d][0] heappush(pq, (a0 * a // gcd(a0, a), a, a0, d)) cnt = len(A_sorted) - 1 while cnt: lcm, a, b, d_prev = heappop(pq) if seen[a]: continue ans += lcm seen[a] = 1 cnt -= 1 for d in div[a]: while mi[d]: if seen[mi[d][0]] == 1: mi[d].popleft() else: break if mi[d]: a_new = mi[d][0] heappush(pq, (a * a_new // gcd(a, a_new), a_new, a, d)) if mi[d_prev]: a_new = mi[d_prev][0] heappush(pq, (b * a_new // gcd(b, a_new), a_new, b, d_prev)) print(ans) if __name__ == '__main__': main()