#!/bin/python import sys def longestSequence(arr): # Return the length of the longest possible sequence of moves. to=0 for j in range(len(arr)): a=arr[j] st=0 if(a%2==0): if(a==2): to+=3 else: for i in range(a-1,1,-1): if(i&(i-1)==0 and a%i==0): st=i break else: if(a==1): to+=1 else: for i in range(3,a+1,1): if(a%i==0): st=i break te=a if(st!=0): to+=a to+=1 while(a!=1): if(te==st): break to+=te/st a=st if(a%2==0): if(a==2): st=1 else: for i in range(a-1,1,-1): if(i&(i-1)==0 and a%i==0): st=i break else: for i in range(3,a+1,1): if(a%i==0): st=i break if(st==a): break a=st return to if __name__ == "__main__": n = int(raw_input().strip()) a = map(long, raw_input().strip().split(' ')) result = longestSequence(a) print result