#!/bin/python3 import sys import math def is_prime(k): if k <2: return False else: for i in range(2,int(math.sqrt(k))+1): if k%i == 0: return False return True def h(k): if k == 1: return 1 if is_prime(k): return k else: s = int(math.sqrt(k)) while s>=2: if k%s == 0 and is_prime(s): return s s = s-1 def longestSequence(a): n = len(a) sum1 = 0 for i in range(n): if a[i]==1: sum1+=1 if is_prime(a[i]): sum1+=a[i]+1 else: l = h(a[i]) moves = 0 n = a[i]//l while(n>=2): if is_prime(n): moves = moves+n+1 n=1 else: moves = moves + 1 n = n//h(n) moves = moves + 1 + moves*(a[i]//l) return moves # Return the length of the longest possible sequence of moves. if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)