Problem:
Score: 300 points

Problem Statement

As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.

Snuke, an employee, would like to play with this sequence.

Specifically, he would like to repeat the following operation as many times as possible:

For every i satisfying 1 \leq i \leq N, perform one of the following: "divide a_i by 2" and "multiply a_i by 3".
Here, choosing "multiply a_i by 3" for every i is not allowed, and the value of a_i after the operation must be an integer.

At most how many operations can be performed?

Constraints

N is an integer between 1 and 10 \ 000 (inclusive).

a_i is an integer between 1 and 1 \ 000 \ 000 \ 000 (inclusive).

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 a_3 ... a_N

Output

Print the maximum number of operations that Snuke can perform.

Sample Input 1

3
5 2 4

Sample Output 1

3

The sequence is initially {5, 2, 4}. Three operations can be performed as follows:

First, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.

Next, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.

Finally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.

Sample Input 2

4
631 577 243 199

Sample Output 2

0

No operation can be performed since all the elements are odd. Thus, the answer is 0.

Sample Input 3

10
2184 2126 1721 1800 1024 2528 3360 1945 1280 1776

Sample Output 3

39

Solution in Haskell (GHC 7.10.3) (judge verdict: Accepted)

import Data.List

main = do
    _ <- getLine
    as <- map read . words <$> getLine
    print $ solve as

solve :: [Int] -> Int
solve = sum . map (length . filter (==2) . primeFactors)

-- Prime.hs
type Pairs a = [(a, Int)]

primes :: Integral a => [a]
primes = 2 : filter ((==1) . length . primeFactors) [3,5..]

primeFactors :: Integral a => a -> [a]
primeFactors n = factor n primes where
    factor m (p:ps)
        | m < 0          = -1 : factor (abs m) (p:ps)
        | p*p > m        = [m]
        | m `mod` p == 0 = p : factor (m `div` p) (p:ps)
        | otherwise      = factor m ps

isPrime :: Integral a => a -> Bool
isPrime 1 = False
isPrime n = case (primeFactors n) of
    (_:_:_)     -> False
    _           -> True

isOddComposit :: Integral a => a -> Bool
isOddComposit n = case (primeFactors n) of
    (2:_:_)     -> False
    (_:_:_)     -> True
    _           -> False

factorize :: Integral a => a -> [a]
factorize 1 = []
factorize n = v : factorize (n `div` v)
    where v = head . primeFactors $ n

primeVectors :: Integral a => a -> Pairs a
primeVectors = count . primeFactors
    where count = map (\xs@(x:_) -> (x, length xs)) . group

combExp :: Integral a => a -> [Pairs a]
combExp n = map (zip primes') . combs $ exps
    where
        pvs = primeVectors n
        primes' = fst . unzip $ pvs
        exps   = snd . unzip $ pvs
        combs [] = [[]]
        combs (x:xs) = [a:as| a <- [0..x], as <- combs xs]

divisors :: Integral a => a -> [a]
divisors n = init . sort . map pvsToNum . combExp $ n
    where pvsToNum = product . map (uncurry (^))