#!/bin/python3 import sys def longestSequence(a): # Return the length of the longest possible sequence of moves. # Return the length of the longest possible sequence of moves. count = 0 for i in a: j=i while j>1: x = [j/2,j/3] #print(x) if j%2==0 and j%3==0: j = max(x) count+=j # print('both',j,count) elif j%2!=0 and j%3==0: j= x[1] count+=j # print('odd',j,count) elif j%2==0 and j%3!=0: j = x[0] count+=j # print('even',j,count) else: # print('prime',j,count) count+=1 break #print(j,count) count+=i return round(count) if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)