#!/bin/python import sys def divisors(n): # get factors and their counts factors = {} nn = n i = 2 while i*i <= nn: while nn % i == 0: if not i in factors: factors[i] = 0 factors[i] += 1 nn //= i i += 1 if nn > 1: factors[nn] = 1 primes = list(factors.keys()) return primes def longestSequence(a): # Return the length of the longest possible sequence of moves. list1=[] total=0 for p in xrange(0,len(a)): query=a[p] list2=divisors(query) list2.sort() q=0 total+=query while query!=1: if query%list2[q]==0: query/=list2[q] total+=query else: q+=1 print total if __name__ == "__main__": n = int(raw_input().strip()) a = map(long, raw_input().strip().split(' ')) result = longestSequence(a)