#!/bin/python from collections import deque import sys def longestSequence(a): # Return the length of the longest possible sequence of moves. if a==1: return a elif a%2==1: return a+1 root = chocBar(a, 1, 0) q = deque([root]) maxMoves=0 while q: curr=q.popleft(); numBars=curr.numBars barLength=curr.barLength currMoves=curr.moves ''' print "---" print "numbars: "+str(curr.numBars) print "barlength: "+str(curr.barLength) print "moves: "+str(curr.moves) print "---" ''' if barLength==2: curr.moves=curr.moves+numBars+(numBars*2) #print "num final moves: "+str(curr.moves) if curr.moves>maxMoves: maxMoves=curr.moves continue changedCurr=0 for i in range(2, barLength+1): if barLength%i==0 and (barLength/i)%2==0: if changedCurr==0: changedCurr=1 curr.moves = currMoves+numBars curr.numBars = numBars*i curr.barLength = barLength/i ''' print "-+-" print "numbars: "+str(curr.numBars) print "barlength: "+str(curr.barLength) print "moves: "+str(curr.moves) print "-+-" ''' q.append(curr) else: newBar=chocBar(barLength/i, numBars*i, currMoves+numBars) q.append(newBar) return maxMoves class chocBar: def __init__(self, barVal, num, m): self.barLength=barVal self.numBars=num self.moves=m if __name__ == "__main__": n = int(raw_input().strip()) a = map(long, raw_input().strip().split(' ')) total=0 for elem in a: total=total+longestSequence(elem) print total