#!/bin/python3 import sys import math primes = {} prime_list = [] pow2s = set() pow2_list = [] def findPrimes(): n = 10**6 + 2 for i in range(2, n): if i not in primes: primes[i] = True prime_list.append(i) j = i while j < n: j += i primes[j] = False def findPow2(): i = 2 n = 10**12 while i <= n: pow2_list.append(i) pow2s.add(i) i*=2 def isPrime(x): if x in primes and primes[x]: return True for i in prime_list: if x%i == 0: return False return True def getMoves(x): if x == 1: return 1 if isPrime(x): return x+1 for i in reversed(prime_list): if x%i == 0: r = getMoves(x//i) return i*r+1 def longestSequence(a): # Return the length of the longest possible sequence of moves. findPrimes() #findPow2() #print(prime_list) return sum(getMoves(x) for x in a) if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)