#!/bin/python3 import sys import math def is_prime(n): if n == 2: return True if n % 2 == 0 or n <= 1: return False sqr = int(math.sqrt(n)) + 1 for divisor in range(3, sqr, 2): if n % divisor == 0: return False return True def largest_prime_factor(n): i = 2 while i * i <= n: if n % i: i += 1 else: n //= i return n def longestSequence(a): # Return the length of the longest possible sequence of moves. res=0 for i in a: if is_prime(i): res+=1+i else: temp=i prod=1 no=1 while temp!=1: #print(no*prod) res+=no*prod prod*=no no=largest_prime_factor(temp) temp=temp//no res+=i return res if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)