#!/bin/python3 import sys import math cache = {1:1, 2:3} cache2 = {} def divisors(n): if n in cache2: return cache2[n] a = [n] for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: a.append(i) a.append(n//i) cache2[n] = a return a def longestSequence(a): total = 0 for n in a: k = 1 if type(n) is tuple: k = n[0] n = n[1] if n in cache: pass elif len(divisors(n)) == 1: cache[n] = n + 1 else: most = 0 for d in divisors(n): most = max(most, d * longestSequence([n // d]) + 1) cache[n] = most total += cache[n] return total if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) a.sort() result = longestSequence(a) print(result)