import math def factor(n): factors = set() while n % 2 == 0: factors.add(2) n //= 2 for i in range(3, int(math.sqrt(n)+1), 2): while n % i == 0: factors.add(i) n //= i if n > 2: factors.add(n) return factors cache = {} def longestSequence(a): # Return the length of the longest possible sequence of moves. if a == 1: return 1 if a in cache: return cache[a] maxi = a for f in factor(a): maxi = max(maxi, f * longestSequence(a // f)) cache[a] = 1 + maxi return 1 + maxi if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) print(sum(map(longestSequence, a)))