Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys

input=sys.stdin.readline
s=input()
t=input()
n,m=len(s),len(t)

ans=[['']*(m+1) for i in range(n+1)]
dp=[[0]*(m+1) for i in range(n+1)]

for i in range(n):
  for j in range(m):
    if s[i]!=t[j]:
      x=dp[i+1][j]
      y=dp[i][j+1]
      if x>y:
        dp[i+1][j+1]=dp[i+1][j]
        ans[i+1][j+1]=ans[i+1][j]
      else:
        dp[i+1][j+1]=dp[i][j+1]
        ans[i+1][j+1]=ans[i][j+1]
    else:
      x=dp[i][j]+1
      y=dp[i+1][j]
      z=dp[i][j+1]
      tmp=max(x,y,z)
      if x==tmp:
        dp[i+1][j+1]=dp[i][j]+1
        ans[i+1][j+1]=ans[i][j]+s[i]
      elif  y==tmp:
        dp[i+1][j+1]=dp[i+1][j]
        ans[i+1][j+1]=ans[i+1][j]
      else:
        ans[i+1][j+1]=ans[i][j+1]
        dp[i+1][j+1]=dp[i][j+1]
print(ans[n][m])

### FIXED CODE ###

import sys

input=sys.stdin.readline
s=input()
t=input()
n,m=len(s),len(t)

dp=[[0]*(m+1) for i in range(n+1)]
ans=[]

for i in range(n):
  for j in range(m):
    if s[i]!=t[j]:
      dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
    else:
      dp[i+1][j+1]=dp[i][j]+1
      
i,j=n,m      
while i>0 and j>0:
  if s[i-1]==t[j-1]:
    ans.append(s[i-1])
    i-=1
    j-=1
  elif dp[i][j]==dp[i-1][j]:
    i-=1
  else:
    j-=1
print(''.join(ans[::-1]))
### BUGGY CODE ###

#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
a, b = LI()
print((a+b+1)//2)
"""

#B
"""
a = S()
a = a[:-1]
b = S()
b = b[:-1]
a.sort()
b.sort(reverse=True)
if a < b:
    print("Yes")
else:
    print("No")
"""

#C
n = I()
a = LI()
seta = set(a)
ans = 0
for i in seta:
    x = a.count(i)
    if x != 0 and x >= i:
        ans += x - i
    else:
        ans += x
print(ans)        

### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
a, b = LI()
print((a+b+1)//2)
"""

#B
"""
a = S()
a = a[:-1]
b = S()
b = b[:-1]
a.sort()
b.sort(reverse=True)
if a < b:
    print("Yes")
else:
    print("No")
"""

#C
n = I()
a = LI()
a.sort()
seta = set(a)
ans = 0
for i in seta:
    x = bisect.bisect_right(a,i) - bisect.bisect_left(a,i)
    if x != 0 and x >= i:
        ans += x - i
    else:
        ans += x
print(ans)
### BUGGY CODE ###

a=0
d=["".join(sorted(input()))for i in range(int(input()))]
for i in list(set(d)):
  n=d.count(i)
  a+=(n-1)*n
print(int(a/2))

### FIXED CODE ###

from collections import *
print(int(sum(([(i-1)*i/2 for i in Counter(["".join(sorted(input()))for i in range(int(input()))]).values()]))))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
jud = []
ans = "YES"
for i in range(n):
  if(a[i] in jud):
    ans = "NO"
    break
  else:
    jud.append(a[i])
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

if len(set(a)) == len(a):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

n = int(input())
V = [int(v) for v in input().split()]

V1 = [V[n] for n in range(0, n, 2)] #v1, v3, v5, ...
V2 = [V[n] for n in range(1, n, 2)] #v2, v4, v6, ...

V1_set = list(set(V1))
V1_cnt = []
for i in V1_set:
  i_cnt = V1.count(i)
  V1_cnt.append([i, i_cnt])
V1_cnt.append([0, 0]) #V1に一種類しか数字が存在しなかったときのために
V1_cnt.sort(key=lambda x: x[1], reverse=True)
  
V2_set = list(set(V2))
V2_cnt = []
for i in V2_set:
  i_cnt = V2.count(i)
  V2_cnt.append([i, i_cnt])
V2_cnt.append([0, 0]) #V2に一種類しか数字が存在しなかったときのために
V2_cnt.sort(key=lambda x: x[1], reverse=True)

mxnum_V1_cnt = V1_cnt[0][0] #V1の中で一番出現回数多い数字
mxnum_V2_cnt = V2_cnt[0][0] #V2の中で一番出現回数多い数字
if mxnum_V1_cnt != mxnum_V2_cnt:
  ans = n - (V1_cnt[0][1] + V2_cnt[0][1])
else:
  ans = n - max(V1_cnt[0][1] + V2_cnt[1][1], V1_cnt[1][1] + V2_cnt[0][1])

print(ans)

### FIXED CODE ###

n = int(input())
V = [int(v) for v in input().split()]

V1 = [V[n] for n in range(0, n, 2)] #v1, v3, v5, ...
V2 = [V[n] for n in range(1, n, 2)] #v2, v4, v6, ...

mx_V1 = max(V1)
V1_cnt = [[0, 0]] # V1に一種類しか数字が存在しなかったときのために
for i in range(1, mx_V1+1):
  V1_cnt.append([i, 0])
for v in V1:
  V1_cnt[v][1] += 1  
V1_cnt.sort(key=lambda x: x[1], reverse=True)

mx_V2 = max(V2)
V2_cnt = [[0, 0]] # V2に一種類しか数字が存在しなかったときのために
for j in range(1, mx_V2+1):
  V2_cnt.append([j, 0])
for v in V2:
  V2_cnt[v][1] += 1  
V2_cnt.sort(key=lambda x: x[1], reverse=True)

mxnum_V1_cnt = V1_cnt[0][0] #V1の中で一番出現回数多い数字
mxnum_V2_cnt = V2_cnt[0][0] #V2の中で一番出現回数多い数字
if mxnum_V1_cnt != mxnum_V2_cnt:
  ans = n - (V1_cnt[0][1] + V2_cnt[0][1])
else:
  ans = n - max(V1_cnt[0][1] + V2_cnt[1][1], V1_cnt[1][1] + V2_cnt[0][1])

print(ans)
### BUGGY CODE ###

import collections
import math

N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
cnt = 0
ansx = []
ansy = []

sumall = 0
for x, y in c.items():
    sumall += (y*(y-1)//2)
    ansy.append(y-1)
    ansx.append(x)

for i in A:
    print(sumall - ansy[ansx.index(i)])


### FIXED CODE ###

import collections
import math

N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
cnt = 0


sumall = 0
for x, y in c.items():
    sumall += (y*(y-1)//2)

for i in range(N):
    print(sumall - c[A[i]] + 1)
### BUGGY CODE ###

s = input()
slist = list(s)
l = len(s)
n = 0
j = 1

while j > 0:
  j = 0
  for i in range(l-1):
    if slist[i] == 'B' and slist[i+1] == 'W':
      slist[i] = 'W'
      slist[i+1] = 'B'
      n += 1
      j += 1

print(n)

### FIXED CODE ###

S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)
### BUGGY CODE ###

from math import sqrt
N = int(input())

for i in range(1,N+1):
    n = int(sqrt(i))
    ans = 0
    for x in range(1,n+1):
        if 6*x*x == i:
            ans +=1
    m = int(sqrt(i/3))
    for x in range(1,m+1):
        for y in range(1,n+1):
            if x!=y:
                if 3*x*x + y*y + 2*x*y == i:
                    ans +=3
    l = int(sqrt(i/6))
    for x in range(1,l+1):
        for y in range(1,x):
            for z in range(1,y):
                if (x+y+z)**2 - x*y - x*z - y*z == i:
                    ans +=6
    print(ans)

### FIXED CODE ###

from math import sqrt
N = int(input())
L = [0 for _ in range(N)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            a = x**2 + y**2 + z**2 + x*y + x*z + y*z
            if a >=1 and a <= N:
                L[a-1] +=1
for x in L:
    print(x)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    a = A[i] % 1000000007
    for j in range(i+1,N):
        b = A[j] % 1000000007
        ans += a*b
        ans = ans % 1000000007
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
mod = 10**9 + 7
for i in range(N):
    a += A[i]
    b += A[i]**2
    a = a 
    b = b 
a = a ** 2 
ans = (a - b) // 2 % mod
if ans < 0:
    ans += mod
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

a,b=map(int,input().split())
ans=int(0)
for i in range(a,b+1):
        ans=ans^i
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import heapq
import fractions
a,b=map(int,input().split())

if a%2==0 and b%2==1:
        if (b-a+1)%4==0:
                print(0)
        else:
                print(1)
elif a%2==0 and b%2==0:
        if (b-1-a+1)%4==0:
                print(b)
        else:
                print(1^b)
elif a%2==1 and b%2==1:
        if (b-1-a+1)%4==0:
                print(a)
        else:
                print(1^a)
elif a%2==1 and b%2==0:
        if (b-1-a)%4==0:
                print(a^b)
        else:
                print(a^b^1)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))

mod_n = 10**9+7

cum_A = [0]
for i in range(n-1):
  cum_A.append(cum_A[i]+A[::-1][i])
  
ans = 0
for i in range(n-1):
  ans += A[i]*cum_A[::-1][i]%mod_n
  
print(ans%mod_n)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
B = A[::-1]

mod_n = 10**9+7

cum_A = [0]
for i in range(n-1):
  cum_A.append(cum_A[i]+B[i])
  
ans = 0
cum_B = cum_A[::-1]
for i in range(n-1):
  ans += A[i]*cum_B[i]%mod_n
  
print(ans%mod_n)
### BUGGY CODE ###

n=int(input())
a = list(map(int,input().split()))
b=0
while(True):
  for i in range(n):
    if(a[i]%2!=0):
      break
    a[i]=a[i]//2
  b+=1
print(b)

### FIXED CODE ###

N=input()
a=list(map(int,input().split()))
i=0
count=-1
b=[]
c=True
while c:
    i=0
    count+=1
    while i<int(N):
        if a[i]%2!=0:
            c=False
            break
        else:
            a[i]=a[i]/2
            i+=1
print(int(count))
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))

from collections import Counter, defaultdict
c = Counter(a)
n1, n2, n3 = c[1], c[2], c[3]
n0 = c[0]
sub = {}
count = [0]
S = sum(a)
for s in range(S+1):
    for i1 in range(s+1):
        for i2 in range((s-i1)//2+1):
            for i3 in range((s-i1-2*i2)//3+1):
                if i1==i2==i3==0:
                    sub[i1,i2,i3] = 0
                    continue
                ans = 1
                p = 0
                if i1>0:
                    ans += i1/n * sub[i1-1,i2,i3]
                    p += i1/n
                if i2>0:
                    ans += i2/n * sub[i1+1,i2-1,i3]
                    p += i2/n
                if i3>0:
                    ans += i3/n * sub[i1,i2+1,i3-1]
                    p += i3/n
                ans = ans/p
                sub[i1,i2,i3] = ans
print(sub[n1,n2,n3])

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))

from collections import Counter, defaultdict
c = Counter(a)
n1, n2, n3 = c[1], c[2], c[3]
n0 = c[0]
def glist(*l, fill=None):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [glist(*ll) for _ in range(l[0])]

count = 0
S = sum(a)
sub = glist(n1+n2+n3+1,n2+n3+1,n3+1)
sub[0][0][0] = 0
#     for i1 in range(min(n+1, s+1)):
#         for i2 in range(min(n+1, (s-i1)//2+1)):
for i3 in range(n3+1):
    for i2 in range(n2+n3+1-i3):
        for i1 in range(n1+n2+n3 - (i2+i3) + 1):
            if i1==i2==i3==0 or i1+i2+i3>n:
                continue
#             print(i1,i2,i3)
            ans = n
            p = 0
            if i1>0:
                ans += i1 * sub[i1-1][i2][i3]
                p += i1
            if i2>0:
                ans += i2 * sub[i1+1][i2-1][i3]
                p += i2
            if i3>0:
                ans += i3 * sub[i1][i2+1][i3-1]
                p += i3
            ans = ans/p
            sub[i1][i2][i3] = ans
print(sub[n1][n2][n3])
### BUGGY CODE ###

# -*- coding:utf-8 -*-
import numpy as np
def button(t):
    tmp = [1]*(t+1)
    tmp2 = [0]*(n-t-1)
    tmp3 = tmp+tmp2
    tmp3 = np.array(tmp3)
    global a
    a = a+tmp3
    return 0

n = int(input())
global a
a = [0]*n
b = [0]*n

for i in range(n):
    a[i],b[i] = map(int,input().split())
a = np.array(a)

count = 0
for i in range(n):
    while True:
        if a[n-1-i] % b[n-1-i] == 0:
            break
        else:
            button(n-1-i)
            count += 1

print(count)

### FIXED CODE ###

n = int(input())
a = [0]*n
b = [0]*n

for i in range(n):
    a[i],b[i] = map(int,input().split())
a.reverse()
b.reverse()
count = 0
for i in range(n):
    if (a[i]+count)%b[i] == 0:
        pass
    elif a[i]+count > b[i]:
        count += (b[i]*(((a[i]+count)//b[i])+1))-(a[i]+count)
    else:
        count += b[i] - (a[i]+count)
print(count)
### BUGGY CODE ###

import numpy as np

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A %= K

ans = 0
sum_from_right = np.zeros(N)

for i in range(N):
    sum_from_right[:i+1] += A[i]
    sum_from_right %= K
    ans += i + 1 - np.count_nonzero(sum_from_right[:i+1] - np.arange(i+1, 0, -1))

print(ans)


### FIXED CODE ###

import numpy as np
from collections import defaultdict

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

counter = defaultdict(int)
ans = 0

for j in range(N+1):
    if j - K >= 0:
        counter[B[j-K]] -= 1
    ans += counter[B[j]]
    counter[B[j]] += 1

print(ans)
### BUGGY CODE ###

N = int(input())
d = list(map(int, input().split()))
count = 0
d.sort()
for i in range((N-2)//2):
    d = d[1:]
    d = d[:-1]
print(d[1]-d[0])


### FIXED CODE ###

N = int(input())
d = list(map(int, input().split()))
count = 0
d.sort()
print(d[N//2]-d[N//2-1])
### BUGGY CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N, W = map(int, input().split())
    w = [None] * N
    v = [None] * N

    for i in range(N):
        w[i], v[i] = map(int, input().split())
    
    dp = [[0]*(N+1) for _ in range(W+1)]
    for i in range(1,W+1):
        for j in range(N):
            if i - w[j] < 0:
                dp[i][j+1] = dp[i][j]
            else:
                dp[i][j+1] = max(dp[i][j], dp[i-w[j]][j]+v[j])
    print(dp[W][N])    

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N, W = map(int, input().split())
    w = [None] * N
    v = [None] * N

    for i in range(N):
        w[i], v[i] = map(int, input().split())
    
    dp = [[0]*(N+1) for _ in range(W+1)]
    for i in range(1,W+1):
        for j in range(N):
            if i - w[j] < 0:
                dp[i][j+1] = dp[i][j]
            else:
                dp[i][j+1] = max(dp[i][j], dp[i-w[j]][j]+v[j])
    print(dp[W][N])    

if __name__ == "__main__":
    main()
### BUGGY CODE ###

a,b,c,k=map(int,input().split())
ta=0
tb=0
tc=0
for i in range(k):
    ta=b+c
    tb=a+c
    tc=a+b
    a=ta
    b=tb
    c=tc
ans=a-b
if ans>10**18:
    print("Unfair")
else:
    print(ans)

### FIXED CODE ###

a,b,c,k=map(int,input().split())
if k%2==0:
    print(a-b)
else:
    print(b-a)
### BUGGY CODE ###

def gcd(x,y):
    if y == 0:
        return x
    return gcd(y, x%y)


K = int(input())
sum = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            A = gcd(a,b)
            B = gcd(A,c)
            sum += B
print(sum)


### FIXED CODE ###

def gcd(x,y):
    if y == 0:
        return x
    return gcd(y, x%y)

K = int(input())
sum = 0
for a in range(1,K-1):
    for b in range(a+1,K):
        for c in range(b+1,K+1):
            sum += gcd(gcd(a,b),c) * 6

for a in range(1,K+1):
    for b in range(1,K+1):
        sum += gcd(gcd(a,b),b) * 3

for i in range(1,K+1):
    sum -=2*i
    
print(sum)
### BUGGY CODE ###

H, W = map(int, input().split())

P = [[0 if x == "#" else 1 for x in input()] for _ in range(H)]
C = [[-3*P[x][y] for y in range(W)] for x in range(H)]

import numpy as np
P = np.array(P, dtype=np.int32)
C = np.array(C, dtype=np.int32)

cur = np.ones(P[0].shape, dtype=np.int32)
for i in range(0, H):
    cur *= P[i]
    C[i] += cur
    cur += 1

cur = 1
for i in range(H-1, -1, -1):
    cur *= P[i]
    C[i] += cur
    cur += 1

cur = np.ones(P[:,0].shape, dtype=np.int32)
for i in range(0, W):
    cur *= P[:,i]
    C[:,i] += cur
    cur += 1

cur = 1
for i in range(W-1, -1, -1):
    cur *= P[:,i]
    C[:,i] += cur
    cur += 1

print(max((x for ci in C for x in ci)))


### FIXED CODE ###

H, W = map(int, input().split())

P = [[0 if x == "#" else 1 for x in input()] for _ in range(H)]
C = [[-3*P[x][y] for y in range(W)] for x in range(H)]

for j in range(W):
    cntU = 0
    cntD = 0
    for i in range(H):
        if P[i][j] == 0:
            cntD = 0
        else:
            cntD += 1
        C[i][j] += cntD 

        if P[H-1-i][j] == 0:
            cntU = 0
        else:
            cntU += 1
        C[H-1-i][j] += cntU 

for i in range(H):
    cntR = 0
    cntL = 0
    for j in range(W):
        if P[i][j] == 0:
            cntR = 0
        else:
            cntR += 1
        C[i][j] += cntR 

        if P[i][W-1-j] == 0:
            cntL = 0
        else:
            cntL += 1
        C[i][W-1-j] += cntL 




print(max((x for ci in C for x in ci)))
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

for k in range(0, min(100, K)):
    work = [0] * N
    for i in range(0, N):
        l = max(0, i - A[i])
        r = min(N - 1, i + A[i])
        work[l] += 1
        if (r + 1 < N):
            work[r + 1] -= 1
    for i in range(1, N):
        work[i] += work[i - 1]
    A = work

print(" ".join([str(item) for item in work]))

### FIXED CODE ###

import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i8[::1],)', cache=True)
def update(A):
    N = len(A)
    B = np.zeros_like(A)
    for i, x in enumerate(A):
        l = max(0, i - x)
        r = min(N - 1, i + x)
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1
    B = np.cumsum(B)
    return B

N, K = map(int, readline().split())
A = np.array(read().split(), np.int64)

K = min(K, 100)
for _ in range(K):
    A = update(A)
print(' '.join(A.astype(str)))
### BUGGY CODE ###

from collections import Counter
N = int(input())
slist = [Counter(input()) for _ in range(N)]
ans = 0
checked = [False] * N
for i in range(N):
    c = 0
    if checked[i]:
        continue
    s = slist[i]
    checked[i] = True
    for j in range(i + 1, N):
        if slist[j] == s:
            c += 1
            checked[j] = True
    ans += sum(range(c + 1))
print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
slist = ["".join(sorted(list(input()))) for _ in range(N)]
c = Counter(slist)
ans = 0
for v in c.values():
    ans += sum(range(v))
print(ans)
### BUGGY CODE ###

N, X = map(int, input().split())
S = sorted([int(a) for a in input().split()])[::-1]
P = 10**9+7
fact = [1]
for i in range(N+10):
    fact.append(fact[-1]*(i+1)%P)

def calc(k, x):
    if k >= N:
        return x
    if x < S[-1]:
        return (x*fact[N-k]) % P
    return (calc(k+1, x%S[k]) + calc(k+1, x) * (N-k-1)) % P

print(calc(0, X))


### FIXED CODE ###

from functools import lru_cache
N, X = map(int, input().split())
S = sorted([int(a) for a in input().split()])[::-1]
P = 10**9+7
fact = [1]
for i in range(N+10):
    fact.append(fact[-1]*(i+1)%P)

@lru_cache(None)
def calc(k, x):
    if k >= N:
        return x
    if x < S[-1]:
        return (x*fact[N-k]) % P
    return (calc(k+1, x%S[k]) + calc(k+1, x) * (N-k-1)) % P

print(calc(0, X))
### BUGGY CODE ###

# D - Ki
import sys
sys.setrecursionlimit(10**7)

N, Q = map(int, input().split())
g = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

# 各頂点に得点を持たせておく
point = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    point[p] += x

ans = [0] * N
def dfs(now, par, pnt):
    ans[now] += pnt + point[now]
    for gi in g[now]:
        if gi!=par:
            dfs(gi, now, ans[now])

dfs(0, 0, 0)

print(' '.join(map(str, ans)))

### FIXED CODE ###

# D - Ki

from collections import deque

n, q = map(int, input().split())

graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

cnt = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    p -= 1
    cnt[p] += x

done = [-1]*n
done[0] = 1
d = deque()
d.append((0, 0))

while len(d)>0:
    v = d.popleft()
    cnt[v[0]] += v[1]
    done[v[0]] = 1
    for i in graph[v[0]]:
        if done[i]<0:
            d.append((i, cnt[v[0]]))

print(' '.join(map(str, cnt)))
### BUGGY CODE ###

import copy

X = int(input())


def cal(x, c):
    if x == 0:
        print(1)
        exit()

    else:
        now = x - 100
        for i in range(6):
            if now < i:
                return 0
            else:
                if c[i] > 19:
                    continue
                else:
                    c2 = copy.deepcopy(c)
                    c2[i] += 1
                    cal(now-i, c2)
    return 0


if X >= 2000:
    print(1)
else:
    print(cal(X, [0 for _ in range(6)]))


### FIXED CODE ###

X = int(input())
for c in range(X//100 + 1):
    if 100*c <= X and X <= 105*c:
        print(1)
        exit()

print(0)
### BUGGY CODE ###

p,q= input().split()
a,b =(int(p), int(q))
wa_count =0
ac_count = 0
pro_num = 0
input_list = [input().split() for i in range(b)]

for i in range(a+1):
    wa_count_f=0
    
    for j in range(b):
        if int(input_list[j][0]) == i:
            if input_list[j][1] == 'WA':
                wa_count_f += 1
            elif input_list[j][1] == 'AC':
                ac_count+= 1
                wa_count += wa_count_f
                break
            
print(ac_count, wa_count)

### FIXED CODE ###

n,m = map(int, input().split())
l = [0] * n

ac = 0
wa = 0
ac_done = [False] * n

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if ac_done[p-1]:
        continue
    else:
        if s == 'AC':
            ac += 1
            wa += l[p-1]
            ac_done[p-1] = True
        else:
            l[p-1] += 1 

print(ac,wa)
### BUGGY CODE ###

import sys
input=sys.stdin.readline

n,m = map(int, input().split())
link = [[] for _ in range(n)]
for i in range(m):
    tmp = list(map(int,input().split()))
    link[tmp[0]-1].append([tmp[1]-1,tmp[2]])
    link[tmp[1]-1].append([tmp[0]-1,-tmp[2]])
from collections import deque
vis=[False]*n
dist=[0]*n
for i in range(n):
    if vis[i]:
        continue
    vis[i] = True
    Q = deque()
    Q.append([i,0])
    while Q:
        now,cnt = Q.popleft()
        vis[now]=True
        for nxt,nxt_dist in link[now]:
            if dist[nxt] != cnt+nxt_dist:# NG or 0
                if vis[nxt]:
                    print("No")
                    exit()
                dist[nxt] = cnt+nxt_dist
            if not vis[nxt]:
                Q.append([nxt,cnt+nxt_dist])
print("Yes")

### FIXED CODE ###

import sys
input=sys.stdin.readline

n,m = map(int, input().split())
link = [[] for _ in range(n)]
for i in range(m):
    tmp = list(map(int,input().split()))
    link[tmp[0]-1].append([tmp[1]-1,tmp[2]])
    link[tmp[1]-1].append([tmp[0]-1,-tmp[2]])
from collections import deque
INF=10**10
dist=[INF]*n
for i in range(n):
    if dist[i]!=INF:
        continue
    dist[i]=0
    Q = deque()
    Q.append([i,0])
    while Q:
        now,cnt = Q.popleft()
        for nxt,nxt_dist in link[now]:
            if dist[nxt] == INF:
                dist[nxt] = cnt+nxt_dist
                Q.append([nxt,cnt+nxt_dist])
            elif dist[nxt] != cnt+nxt_dist:
                    print("No")
                    exit()

print("Yes")
### BUGGY CODE ###

if __name__ == '__main__':
	input()
	A = list(map(int,input().split()))

	cnt = 0
	EVE = [i for i in A if i % 2 == 0]
	EVE.sort()

	while True:
		if len(EVE) == 0:
			print(cnt)
			break
		else:
			EVE[-1] = EVE[-1] // 2
			if EVE[-1] % 2 == 1:
				EVE.pop(-1)
			else:
				EVE.sort()
			cnt += 1


### FIXED CODE ###

import sys

if __name__ == '__main__':
	input()
	A = list(map(int,sys.stdin.readline().split()))

	cnt = 0
	EVE = [i for i in A if i % 2 == 0]

	for j in EVE:
		while True:
			j = j // 2
			if j % 2 == 1:
				cnt += 1
				break
			cnt += 1

	print(cnt)