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



Sample input:
3
5 2 4


Sample output:
3

Submission status: Runtime Error

Solution code:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = ans + (len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Submission status: Runtime Error

Solution code:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = max(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Submission status: Runtime Error

Solution code:
n = map(int, input())
alist = list(map(int, input().split(" ")))

def do_sunuke(l, cnt) : 
    reslist = []
    flg_div2 = 0

    for a in l :
        if a % 2 == 0 and flg_div2 == 0 :
            reslist.append(int(a/2))
            flg_div2 = 1
        else :
            reslist.append(a)

    if flg_div2 == 0 :
        return cnt
    else : 
        return do_sunuke(reslist, cnt + 1)
    
print(do_sunuke(alist, 0))

Submission status: Runtime Error

Solution code:
input()
def f(a):
  a = int(a)
  r = 0
  while a % 2 == 0:
    a /= 2
    r += 1
  return r
print(sum(map(f,input.split())))

Submission status: Runtime Error

Solution code:
n = int(input())
as = list(map(int, input().split()))

r = 0
i = 1
while True:
  f = False
  for a in as:
    if a%2 == 0:
      a /= 2
      r += 1
      f = True
  if not f:
    break
print(r)

Submission status: Runtime Error

Solution code:
n = int(input())
as = list(map(int, input().split()))

r = 0
i = 1
while True:
  for a in as:
    f = False
    if a%2 == 0:
      a /= 2
      r += 1
      f = True
    if not f:
      break
print(r)

Submission status: Runtime Error

Solution code:
n = map(int,input().split())
lis = list(map(int,input().split()))
ans = 0
def f(x):
 if x%2:
  return(0)
 else:
  return(f(x//2)+1)
for i in range(n):
 ans += f(lis[i])
print(ans)

Submission status: Runtime Error

Solution code:
n = map(int,input().split())
lis = list(map(int,input().split()))
ans = 0
def f(x):
 if x%2:
  return 0
 else:
  return f(x//2)+1
for i in range(n):
 ans += f(lis[i])
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = map(int, raw_input().split())
a = np.array( [] )
a = np.append(a,map(int, raw_input().split()))

prod = a.prod()
out  = 0

while prod%2 == 0:
    prod = prod/2
    out = out +1

print out

Submission status: Runtime Error

Solution code:
N = input()
nums = list(map(int, input().split()))
cnt = 0
cntlst = []
for i in range (0,N-1):
    taisyouN = nums[i]
    while taisyouN %2 == 0:
        taisyouN = taisyouN/2
        cnt = cnt+1
print(cnt)

Submission status: Runtime Error

Solution code:
N = input()
nums = list(map(int, input().split()))
cnt = 0
for i in range(0,n-1):
    taisyouN = nums[i]
    while taisyouN %2 == 0:
        taisyouN = taisyouN/2
        cnt = cnt+1
print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
suuretu = [int(x) for x in input().split()]
answer = 0
 
for i in suuretu:
    answer += calculate(i)
 
def calculate(i):
    a = 0
    while i % 2 == 0:
        i = i / 2
        a += 1
    return a

print(answer)

Submission status: Runtime Error

Solution code:
n = input()
a = list(map(int,input().split()))
x = 0
for i in range(n):
    y = a[n]
    while y%2 == 0:
        x = x + 1
        y = y/2
print(y)

Submission status: Runtime Error

Solution code:
from math import log2

N = input()
number = input()

a = number.split()
n_list=[]
count=0



for num in a:
    num = int(num)
    if num % 2 == 0:
        n_list.append(num)


if n_list != []:
    maxnum = max(n_list)
    maxnum = log2(maxnum)
    for num2 in n_list:
        for i in range(maxnum):
            if num2 % 2**(i+1) == 0:
                count+=1


print(count)

Submission status: Runtime Error

Solution code:
N = input()
number = input()

a = number.split()
n_list=[]
count=0



for num in a:
    num = int(num)
    if num % 2 == 0:
        n_list.append(num)


if n_list != []:
    maxnum = max(n_list)
    maxnum = maxnum/2
    for num2 in n_list:
        for i in range(maxnum):
            if num2 % 2**(i+1) == 0:
                count+=1


print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
suuretu = [int(x) for x in input().split()]
answer = 0

for i in suuretu:
    answer += calculate(i)

def calculate(i):
    a = 0
    while i % 2 == 0:
        i = i / 2
        a += 1

    return a


print(answer)

Submission status: Runtime Error

Solution code:
suuretu = [int(x) for x in input().split()]
answer = 0

for i in suuretu:
    answer += calculate(i)

def calculate(i):
    a = 0
    while i % 2 == 0:
        i = i / 2
        a += 1

    return a


print(answer)

Submission status: Runtime Error

Solution code:
from math import log2


def action(nums, start=0):
    if any([e % 2 == 0 for e in nums]):
        return max([action(convert(nums, i), start+1) for i, e in enumerate(nums) if e % 2 == 0])
    else:
        return start

def convert(nums, i):
    alt_nums = nums[:]
    alt_nums[i] = nums[i] // 2
    return alt_nums

def main():
    _n = int(input())
    nums = [int(x) for x in input().split()]

    print(action(nums))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
suuretu = [int(x) for x in input().split()]
answer = 0

for i in suuretu:
    answer += calculate(i)


def calculate(int):
    a = 0
    while int % 2 == 0:
        int = int / 2
        a += 1
    
    return a 

print(answer)

Submission status: Runtime Error

Solution code:
def run(n, a):
    cnt = 0
    for i in range(n):
        while a[i] % 2 == 0:
            a[i] /= 2
            cnt += 1
    return cnt


def read_line():
    n = input().split()
    a = input().split()
    n = int(n)
    a = [int(a[i] for i in range(len(a)))]
    return (n, a)


def main():
    n, a = read_line()
    print(run(n, a))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
b = 0
#print(a)
for i in range(N):
    while a[i] %2 == 0:
        b += 1
        a[i] /= 2
print(b)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

d = deque(A)
c = 0
while(len(d)>0):
    tmp = d.pop()
    if tmp%2==0:
        c+=1
        d.append(tmp//2)
print(c)

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
a = list(filter(lambda x: x%2==0, a))
if len(a) == 0:
    print(0)
else:
    a = sorted(a, reverse=True)
    ans = 0
    while len(a):
        a[0] /= 2
        for i in range(1,len(a)):
            a[i] *= 3
        a = list(filter(lambda x: x%2==0, a))
        a = sorted(a, reverse=True)
        ans += 1
    print(ans)

Submission status: Runtime Error

Solution code:
# input 
n = map(int, input())
a = map(int, input().split(" "))

# make list 
curlist = list(a)

# du recurse
def sunukeList(curlist, cnt) :
    print("DBG : ", curlist)
    reslist = []
    flg_div2 = 0
    flg_did3 = 0

    for i in curlist :    
        # if divisible by two then divide
        if i%2 == 0 and flg_div2 == 0: 
            reslist.append(int(i/2))
            flg_div2 = 1
        else :
            reslist.append(i*3)
            flg_did3 = 1

    if flg_div2 == 0 :
        print(cnt)
    else :
        sunukeList(reslist, cnt + 1)
        
# calc
sunukeList(curlist, 0)

Submission status: Runtime Error

Solution code:
from collections import deque
from collections import namedtuple

N = int(input())
A = [int(i) for i in input().split()]
Prog = namedtuple("Prog","p,c")
d = deque([(deque(A),0)])
ans = 0
while(len(d)>0):
    tmp = d.pop()
    tmp2 = deque()
    for i in gen(tmp[0]):
        tmp2.appendleft(i.p)
    tmp2.pop()
    if len(tmp2) < 1:
        if ans < tmp[1]:
            ans = tmp[1]
    else:
        for i in tmp2:
            d.appendleft((i,tmp[1]+1))
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
arr=[int(a) for a in input().split()]
ans=0
for i in range(i):
   c=0
   while arr[i]%2 ==0:
      arr[i]=arr[i]//2
      c=c+1
   ans=ans+c

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
nums = list(map(int, input().split()))


def renew(arr):
    res = []
    changed = False
    for i in arr:
        if not i & 1 and not changed:
            res.append(int(i / 2))
            changed = True
        else:
            res.append(i * 3)
    if changed:
        return res
    else:
        return []


count = 0
cs = renew(nums)
print(cs)
while len(cs) > 0:
    count += 1
    cs = renew(cs)


print(count)

Submission status: Runtime Error

Solution code:
MAX = 1000000000

n = int(input().rstrip())
a = [int(temp) for temp in input().rstrip().split(" ")]

count = 0

while True:

    a.sort()
    a.reverse()

    is_success = True

    div_flag = False
    for i in range(n):
        if div_flag == False and a[i] % 2 == 0:
            a[i] = int(a[i] / 2)
            div_flag = True
        else:
            a[i] = a[i] * 3

        # (MAX < a[i] * 3 and a[i] % 2 != 0)
        if div_flag == False and i == n-1:
            is_success = False

    if is_success:
        count += 1
    else:
        break


print(count)

Submission status: Runtime Error

Solution code:
import math
N=int(input())
arr=[int(a) for a in input().split()]
ans=0
for i in range(N):
   ans=ans+int(math.log2(arr[N]))

print(ans)

Submission status: Runtime Error

Solution code:
import math
N=int(input())
arr=[int(a) for a in input().split()]
ans=0
for i in range(N):
   ans=ans+math.log2(arr[N])

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
count = 0
judge = False

#奇数
odd = []
#偶数
even = []

# 奇数と偶数に分ける
for i_a in range(len(a)):
    if(a[i_a] % 2 == 0):
        even.append(a[i_a])
    else:
        odd.append(a[i_a])
# もし偶数がいない場合は操作不可能
if(even == []):
    print(0)
    exit()

# 偶数を一つ取り出し、2で割る。次で割れなくなるなら削除
max_odd = max(odd)
while True:
    count += 1
    even[0] /= 2
    if(even[0] % 2 != 0):
        even.pop(0)
    if(even == []):
        break
        

print(count)


# while True:
#     for i_a in range(len(a)):
#         judge = False
#         if(a[i_a] % 2 == 0):
#             a[i_a] /= 2
#             count += 1
#             judge = True
#             break
#         else:
#             a[i_a] *= 3
        
#     if(not judge):
#         print(count)
#         print(a)
#         exit()


# while True:
#     for i_a in range(len(a)):
#         judge = False
#         if(a[i_a] % 2 == 0):
#             a[i_a] /= 2
#             judge = True
#             break
#         else:
#             a[i_a] *= 3
        
#     if(not judge):
#         print(count)
#         exit()
#     else:
#         count += 1

Submission status: Runtime Error

Solution code:
import functools
import operator

count = 0
N = int(input())
L = list(map(int,input().split( )))

L2 = functools.reduce(operator.mul,L)

for l in range(L2):
    if L2%2 == 0:
        L2 /= 2
        count += 1
    else:
        break

print(count)

Submission status: Runtime Error

Solution code:
n = int(raw_input())
a = map(int, raw_input().split())
number = 0

for i in xrange(n):
  while a[n] % 2 == 0:
    number += 1
    a[n] /= 2
    
print number

Submission status: Runtime Error

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(input())

c=0
m = max(a%2)
for i in a:
    c =+ i//2
    if m*(3**c) > 1000000000:
        break
        
print(c)

Submission status: Runtime Error

Solution code:
N=input()
li = list(map(int,input().split()))

mal = 1
for i in li:
    mal = mal * i
cnt =0
while mal % 2 == 0:
    mal = mal / 2
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
inp2 = input()
a = inp2.split()
count = 0
for i in range(int(N)):
	b = int(a[i])
	flag = True
	while flag:
		c = b/2
		if c.isinstance(c,int):
			count+=1
		else:
			flag = False

print(count)

Submission status: Runtime Error

Solution code:
suuretu = [int(x) for x in input().split()]
n = len(suuretu)
answer = 0

for i in suuretu:
    calculate(i)

def calculate(int):
    while int%2 == 0:
        int = int / 2
        answer += 1

print (answer)

Submission status: Runtime Error

Solution code:
N = int(input())
inp2 = int(input())
a = inp2.split()
count = 0
for i in range(int(N)):
	b = int(a[i])
	flag = True
	while flag:
		c = b/2
		if c.isinstance(c,int):
			count+=1
		else:
			flag = False

print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 0

for i in len(A):
    while A[i] % 2 = 0:
        ans += 1
        A[i] //= 2

print(ans)

Submission status: Runtime Error

Solution code:
res = 0
for a in A:
    count = 0
    while True:
        if a % 2 == 0:
            count += 1
            a = a / 2
        else:
            break
    res += count

Submission status: Runtime Error

Solution code:
N = int(input())
a = np.array(input().split()).astype(int)

sum = 0
for i in range(len(a)):
    sum += a[i]%2
print(sum)

Submission status: Runtime Error

Solution code:
N=int(input().strip())
A=list(map(int,input().split()))
nns=[2**i for i in range(31)]
def func(n,x):
    return n%nns[x]==0
def binsearch_int(func, min_x, max_x):
    """func(x) == Trueとなる最大のxを返す
    """
    if func(max_x):
        return max_x
    if not func(min_x):
        return None
    left,right=min_x,max_x
    while left+1<right:
        mid=(left+right)//2
        if func(mid):
            left=mid
        else:
            right=mid
    return left
sum(binsearch_int(lambda x: func(i,x),0,int(math.log2(i))+1) for i in A)

Submission status: Runtime Error

Solution code:
for i in a:
    while i%2==0:
        i/=2
        ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input().strip())

A = map(int, input().strip().split())

if all([a // 2 == 1 for a in A]):
  print(0)
else:
  A = [bin(a) for a in A]
  for a in A:
    if a[-1] == '1':
      continue
    for b, i in zip(a[2:], reversed(range(len(a) - 2))):
      c += int(b) * i
  print(c)