def longestSequence(a): import math def make_primes(num): if num < 2: return [] num_sqrt = math.sqrt(num) candidates = [i for i in range(2, num + 1)] primes = [] while True: target = candidates.pop(0) primes.append(target) candidates = [i for i in candidates if i % target != 0] if not candidates: break if candidates[0] > num_sqrt: primes.extend(candidates) break return primes def largest_divisor(num, primes): for prime in primes: if num % prime == 0: return num // prime return 1 def longest(n): if n < 2: return n array = [n] primes = make_primes(100000) while True: target = largest_divisor(n, primes) array.append(target) if target == 1: break n = target return sum(array) return sum([longest(i) for i in a]) if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)