#!/bin/python3 import sys #BREAK IT INTO PIECES WITH THE MOST FACTORS #WHEN TIES, BREAK IT INTO THE MOST PIECES(SMALLEST PIECES) import math def largest_factor(n): for i in range(2, math.ceil(math.sqrt(n))): if n%i == 0: return n//i return 1 def longestSequence(a): # Return the length of the longest possible sequence of moves. moves = 0 for i in a: LF = i moves += LF while not LF == 1: LF = largest_factor(LF) moves+=LF return moves if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)