#!/bin/python3 import sys def longestSequence(a): # Return the length of the longest possible sequence of moves. total_moves=0 for val in a: moves=0 if val == 1: total_moves +=1 continue pieces=1 indiv_pieces=1 indiv_val=val if val % 2 == 0: while True: moves +=pieces if indiv_val % 3 == 0: indiv_val=int(indiv_val/3) pieces=int(val/indiv_val) else: indiv_val=int(indiv_val/2) pieces=int(val/indiv_val) if pieces==val: break else: moves +=1 total_moves =total_moves+moves+val return total_moves if __name__ == "__main__": n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = longestSequence(a) print(result)