#!/bin/python3 import sys def eratosthenes(): '''Yields the sequence of prime numbers via the Sieve of Eratosthenes.''' D = {} q = 2 while 1: if q not in D: yield q D[q*q] = [q] else: for p in D[q]: D.setdefault(p+q,[]).append(p) del D[q] q += 1 def all_primes(stick): possible_factors = [1] factory = eratosthenes() for i in range(stick//2): if possible_factors[-1] <= stick//2: possible_factors.append(factory.__next__()) return possible_factors[:-1] def factorize(stick): factors = [] possible_list = all_primes(stick)[1:] #print(possible_list) cannonical_list = [] for element in possible_list: if stick % element == 0: factors.append(element) for element in reversed(factors): while stick % element == 0: stick = stick / element cannonical_list.append(element) if len(cannonical_list) == 0: cannonical_list.append(stick) #print(cannonical_list) return cannonical_list def smart_cannonical(n): next_prime = eratosthenes() cannonical_list = [] if n == 1: return [1] while n != 1: cur_prime = next_prime.__next__() while n % cur_prime == 0: cannonical_list.append(cur_prime) n = n//cur_prime #print(cannonical_list) return cannonical_list def bestSequence(stick): moves = 0 previous = 1 for element in reversed(smart_cannonical(stick)): previous = previous * element moves += previous if moves == 1: return moves return moves+1 def longestSequence(a): # Return the length of the longest possible sequence of moves. sum_of_all_sticks = 0 for element in a: sum_of_all_sticks += bestSequence(element) return sum_of_all_sticks if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)