#!/bin/python3 import sys import itertools import math memo = {} def prime_factorization(n): res = [] while n > 1: for i in itertools.chain([2], range(3, int(math.sqrt(n))+1, 2), [n]): if n % i == 0: res.append(i) n //= i break return res def max_moves(stick_len, factorization=None): # To obtain the max number of moves, we essentially have to maximize # 1.tree height and 2. branches at each level. # For 1. divide by prime factors only. # For 2. divide by the greatest divisor (less than the piece length itself) # Put the two together and you have the solution: divide at each level by the greatest prime divisor. if stick_len in memo: return memo[stick_len] if factorization is None: factorization = prime_factorization(stick_len) if len(factorization) == 0: return 1 div = factorization.pop() moves = 1 + div * max_moves(stick_len//div, factorization=factorization) memo[stick_len] = moves return moves def longestSequence(a): # Return the length of the longest possible sequence of moves. result = 0 for stick in a: result += max_moves(stick) return result if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)