#!/bin/ruby def logable(n) return false if n==1 return Math.log(n,2)%Math.log(n,2).floor==0 end def longestSequence(a) # Return the length of the longest possible sequence of moves. sum = 0 for i in 0..a.length-1 sum += longestSequenceForOne(a[i]) end sum end def longestSequenceForOne(num) ori = num sum = 1 if num == 1 return 1 end while !logable(num) # p "inside !logable" for i in 3..num/2 #p "inside for loop i is #{i}" if num%i==0 num = num/i sum += i break end if i == num/2 return sum + ori end end end if logable(num) for i in 0..Math.log(num,2).to_i-1 #p "inside logable" sum += ori/(2**i) end end return sum end n = gets.strip.to_i a = gets.strip a = a.split(' ').map(&:to_i) result = longestSequence(a) puts result