#!/bin/python3 import sys, math from fractions import gcd from random import randint def factorize(n): def isPrime(n): return not [x for x in range(2, int(math.sqrt(n)) + 1) if n%x == 0] primes = [] candidates = range(2, int(n) + 1) candidate = 2 while not primes and candidate in candidates: if n%candidate == 0 and isPrime(candidate): primes = primes + [candidate] + factorize(n/candidate) candidate += 1 return primes def brent(N): # brent returns a divisor not guaranteed to be prime, returns n if n prime if N%2==0: return 2 y,c,m = randint(1, N-1),randint(1, N-1),randint(1, N-1) g,r,q = 1,1,1 while g==1: x = y for i in range(r): y = ((y*y)%N+c)%N k = 0 while (k1: break return g def factorize2(n1): if n1<=0: return [] if n1==1: return [1] n=n1 b=[] p=0 mx=1000000 while n % 2 ==0 : b.append(2);n//=2 while n % 3 ==0 : b.append(3);n//=3 i=5 inc=2 #use trial division for factors below 1M while i <=mx: while n % i ==0 : b.append(i); n//=i i+=inc inc=6-inc #use brent for factors >1M while n>mx: p1=n #iterate until n=brent(n) => n is prime while p1!=p: p=p1 p1=brent(p) b.append(p1);n//=p1 if n!=1:b.append(n) b.sort() return b def longestSequence(a): # Return the length of the longest possible sequence of moves. total_moves = 0 for stick in a: if stick != 1: factors = (factorize2(stick)) factors = list(reversed(factors)) moves = factors[0] prev_summation = factors[0] for index in range(len(factors) - 1): summation = prev_summation * factors[index +1] moves += summation prev_summation = summation else: moves = 0 total_moves += moves + 1 return(int(total_moves)) if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)