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

N = int(input())
num_list = list(map(int, input().split()))

import collections
answer_list = []

for i in range(N):
    new_list = num_list[0:i]+num_list[i+1:N]
    c = collections.Counter(new_list)

    comb = 0

    for value in c.values():
        comb += value*(value-1)/2

    answer_list.append(comb)

for i in answer_list:
    print(int(i))

### FIXED CODE ###

N = int(input())
num_list = list(map(int, input().split()))

from collections import defaultdict
d = defaultdict(int)
for i in num_list:
  d[i] += 1
 
total = 0
for i in set(num_list):
  x = d[i]
  total += x*(x-1)/2
 
for i in num_list:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))
### BUGGY CODE ###

N,M =list(map(int,input().split()))
H = list(map(int,input().split()))

h = [[0] * N for i in range(N)]
ans = 0
for i in range(M):
    A,B = list(map(int,input().split()))
    h[A-1][B-1] = H[B-1]
    h[B-1][A-1] = H[A-1]

for i in range(N):
    if H[i] >max(h[i]) or max(h[i])== 0:
        ans += 1
print(ans)

### FIXED CODE ###

N,M =list(map(int,input().split()))
H = list(map(int,input().split()))

h = [0] * N 
ans = 0
for i in range(M):
    A,B = list(map(int,input().split()))
    h[A-1] = max(H[B-1],h[A-1])
    h[B-1] = max(H[A-1],h[B-1])

for i in range(N):
    if H[i] >h[i] or h[i] == 0:
        ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
d = map(int, input().split())
d = sorted(d)
l = []
now = 0
ans = 0
for i in range(n-1):
    if d[i] != d[i+1]:
        a = d.index(d[i])
        b = d.count(d[i])
        index = a+b-1
        #print(index)
        if index+1 == n/2:
            #print(d[i+1], d[i])
            ans = d[i+1]-d[i]
print(ans)

### FIXED CODE ###

n = int(input())
d = map(int,input().split())
d = sorted(d)
print(d[int(n/2)]-d[int(n/2)-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

INF = float("inf")
dp = [0] + [INF] * 10**5

for _ in range(N):
  w, v = map(int, input().split())
  for j in range(10**5, v-1, -1):
    dp[j] = min(dp[j], dp[j-v] + w)

for i, x in enumerate(dp):
  if x <= W:
    ans = i

print(ans)

### FIXED CODE ###

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

INF = 10**11 + 1
dp = [[INF]*(10**5 + 1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
  w, v = map(int, input().split())
  for j in range(10**5 + 1):
    dp[i+1][j] = min(dp[i][j], dp[i][max(0, j-v)] + w)

ans = 0
    
for i, x in enumerate(dp[-1]):
  if x <= W:
    ans = i

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

# F - Pond Skater

from collections import deque

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x1 -= 1
y1 -= 1
x2 -= 1
y2 -= 1
grid = []
for _ in range(H):
    grid.append(list(str(input())))

dist = [[-1] * W for _ in range(H)]
dist[x1][y1] = 0
q = deque()
q.append((x1, y1))

while q:
    (x, y) = q.popleft()
    if (x, y) == (x2, y2):
        break
    for vx, vy in ((0, 1), (1, 0), (0, -1), (-1, 0)):
        for k in range(1, K+1):
            nx = x + vx*k
            ny = y + vy*k
            if nx < 0 or nx >= H or ny < 0 or ny >= W or grid[nx][ny] == '@':
                break
            if dist[nx][ny] == -1:
                dist[nx][ny] = dist[x][y] + 1
                q.append((nx, ny))

print(dist[x2][y2])

### FIXED CODE ###

# F - Pond Skater

from collections import deque

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
x1 -= 1
y1 -= 1
x2 -= 1
y2 -= 1
grid = []
for _ in range(H):
    grid.append(list(str(input())))

dist = [[-1] * W for _ in range(H)]
dist[x1][y1] = 0
q = deque()
q.append((x1, y1))

while q:
    (x, y) = q.popleft()
    if (x, y) == (x2, y2):
        break
    for vx, vy in ((0, 1), (1, 0), (0, -1), (-1, 0)):
        for k in range(1, K+1):
            nx = x + vx*k
            ny = y + vy*k
            if nx < 0 or nx >= H or ny < 0 or ny >= W or grid[nx][ny] == '@':
                break
            if dist[nx][ny] != -1 and dist[nx][ny] != dist[x][y] + 1:
                break
            if dist[nx][ny] == -1:
                dist[nx][ny] = dist[x][y] + 1
                q.append((nx, ny))

print(dist[x2][y2])
### BUGGY CODE ###

import sys
import math
from collections import deque

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

dp = [10 ** 9 for _ in range(N)]
dp[0] = 0

for i in range(1, N):
    MIN = 10 ** 9
    for l in range(K):
        if i-(l+1) < 0:
            continue
        else:
            MIN = min(MIN, dp[i - (l + 1)] + abs(h[i] - h[i - (l + 1)]))
    dp[i] = MIN
print(dp[N - 1])


### FIXED CODE ###

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

dp = [[10**9 for _ in range(K+1)] for _ in range(N)]
dp[0] = [0 for _ in range(K+1)]

for i in range(N):
    for l in range(K):
        if i-(l+1) >= 0:
            dp[i][l] = dp[i - (l + 1)][K] + abs(h[i] - h[i - (l + 1)])
        else:
            dp[i][l] = min(dp[i])
        if l == K-1:
            dp[i][K] = min(dp[i])
print(min(dp[N-1]))
### BUGGY CODE ###

import math
mod = 10**9+7
n,k = map(int,input().split())
b = math.factorial(k-1)%mod
def comb(p):
    if p >= k-1:
        a = math.factorial(p)%mod
        c = math.factorial(p-k+1)%mod
        return (a*pow(b*c, mod-2, mod))%mod
    else:
        return 0
A = list(map(int,input().split()))
A.sort()
maxlist = []
ans = 0
for i in range(k-1,n):
    maxlist.append(comb(i))
for i in range(k-1,n):
    ans += (A[i]*maxlist[i-k+1])%mod
    ans %= mod
cur = len(maxlist)-1
for i in range(k-1,n):
    ans += mod-((A[i-k+1]*maxlist[cur])%mod)
    ans %= mod
    cur -= 1
print(ans)


### FIXED CODE ###

import math
mod = 10**9+7
n,k = map(int,input().split())
b = math.factorial(k-1)%mod
fact = [0]*(n-k+1)
a = math.factorial(k-1)%mod
c = 1
for i in range(k-1, n):
    if i == k-1:
        fact[0] = (a*pow(b*c, mod-2, mod))%mod
    else:
        a = a*i%mod
        c = c*(i-k+1)%mod
        fact[i-k+1] = (a*pow(b*c, mod-2, mod))%mod
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(k-1,n):
    ans += fact[i-k+1]*(A[i]-A[n-i-1])
    ans %= mod
print(ans)
### BUGGY CODE ###

# d
I = lambda: map(int, input().split())
n, k = I()
a = []
for _ in range(n):
    t, d = I()
    a += [d, t],
a.sort(key = lambda x: x[0], reverse = True)
b = 0
c = [0]*(n+1)
e = 0
s = []
for i in a[:k]:
    b += i[0]
    if c[i[1]] == 0: e += 1
    c[i[1]] += 1
    s += i,
f = b+e**2
for i in range(k, n):
    g = a[i]
    if c[g[1]] > 0: continue
    for j in range(k):
        h = s[::-1][j]
        if c[h[1]] > 1:
            b += g[0]-h[0]
            c[g[1]] += 1
            c[h[1]] -= 1
            s.pop(j)
            s += g,
            e += 1
            f = max(f, b+e**2)
            break
print(f)

### FIXED CODE ###

mi = lambda: map(int, input().split())
n, k = mi()
sushis = [list(mi()) for _ in range(n)]
types = set()
sushis.sort(key = lambda x: x[1], reverse = True)
bp = tp = sp = 0
exts = []
for t, d in sushis[:k]:
    bp += d
    if t in types:
        exts += d,
    else:
        types.add(t)
        tp += 1
sp = bp+tp**2
for t, d in sushis[k:]:
    if not exts: break
    if t not in types:
        types.add(t)
        bp += d-exts.pop()
        tp += 1
        sp = max(sp, bp+tp**2)
print(sp)
### BUGGY CODE ###

def main():
    a = int(input())
    b = list(map(int, input().split()))
    for i in range(1,a+1):
        print(b.count(i))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    a = int(input())
    b = list(map(int, input().split()))
    c = [0]*a
    for i in b:
        c[i-1] += 1
    for j in c:
        print(j)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [[0, 0] for i in range(60)]
for a in A:
  for i in range(60):
    digit[i][int(a[i])] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i][0] * digit[i][1])
print(ans %Num)

### FIXED CODE ###

N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [0 for i in range(60)]
for a in A:
  for i in range(60):
    if a[i] == "1":
      digit[i] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i] * (N-digit[i])) %Num
print(ans)
### BUGGY CODE ###

from heapq import heappush, heappop 
INF = 10 ** 100
n, m, s, t = map(int, input().split())
s -= 1
t -= 1
init = 10 ** 15
edges = [[] for _ in range(n * 2)]
for _ in range(m):
  u, v, a, b = map(int, input().split())
  u -= 1
  v -= 1
  edges[u].append((v, a))
  edges[v].append((u, a))
  edges[u + n].append((v + n, b))
  edges[v + n].append((u + n, b))

for i in range(n):
  edges[i].append((i + n, 0))

for i in range(n):
  if i >= 1:
    edges[i - 1].remove((i - 1 + n, 0))

  que = []
  heappush(que, (0, s))
  costs = [INF] * (n * 2)
  costs[s] = 0
  while que:
    total, node = heappop(que)
    for to, dist in edges[node]:
      if costs[to] > total + dist:
        costs[to] = total + dist
        heappush(que, (total + dist, to))
  print(init - costs[t + n])

### FIXED CODE ###

from heapq import heappush, heappop 
def main():
  INF = 10 ** 20
  n, m, s, t = map(int, input().split())
  s -= 1
  t -= 1
  init = 10 ** 15
  edges1 = [[] for _ in range(n)]
  edges2 = [[] for _ in range(n)]
  for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    edges1[u].append((v, a))
    edges1[v].append((u, a))
    edges2[u].append((v, b))
    edges2[v].append((u, b))
  
  from_s = [INF] * n
  from_s[s] = 0
  que = []
  heappush(que, (0, s))
  while que:
    total, node = heappop(que)
    for to, dist in edges1[node]:
      if from_s[to] > total + dist:
        from_s[to] = total + dist
        heappush(que, (total + dist, to))
  
  from_t = [INF] * n
  from_t[t] = 0
  que = []
  heappush(que, (0, t))
  while que:
    total, node = heappop(que)
    for to, dist in edges2[node]:
      if from_t[to] > total + dist:
        from_t[to] = total + dist
        heappush(que, (total + dist, to))

  save = []
  for i in range(n):
    save.append(init - from_s[i] - from_t[i])
  save.reverse()
  acc = 0
  ans = []
  for s in save:
    acc = max(acc, s)
    ans.append(acc)
  ans.reverse() 
  for i in range(n):
    print(ans[i])

main()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
edge = {}
edge[0, 1] = min(A[0], A[1])
edge[1, 0] = min(A[0], A[1])
ans = A[0]
max_edge_list = [(0, 1), (1, 0)]
#print(edge)
for i in range(2, N):
    max_kv = max(edge.items(), key=lambda x: x[1])
    x, y = max_edge_list[0]
    ans += edge[(x, y)]
    del edge[(x, y)]
    edge[x, i] = A[i]
    edge[i, y] = A[i]
    max_edge_list.append((x, i))
    max_edge_list.append((i, y))
    max_edge_list.remove((x, y))
    #print(edge)
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
edge = {}
edge[0, 1] = min(A[0], A[1])
edge[1, 0] = min(A[0], A[1])
ans = A[0]
max_edge_list = [(0, 1), (1, 0)]
idx = 0
for i in range(2, N):
    x, y = max_edge_list[idx]
    ans += edge[(x, y)]
    #del edge[(x, y)]
    edge[x, i] = A[i]
    edge[i, y] = A[i]
    max_edge_list.append((x, i))
    max_edge_list.append((i, y))
    #max_edge_list.pop(0)
    idx += 1
print(ans)
### BUGGY CODE ###

count = int(input())
nums = input().split(" ")

product = 1

for i in range(count):
    product *= int(nums[i])

if (product > 10**18):
    print(-1)
else:
    print(product)

### FIXED CODE ###

count = int(input())
nums = input().split(" ")

product = 1

if ("0" in nums):
    print(0)
else:
    for i in nums:
        product *= int(i)
        if (product > 10**18):
            print(-1)
            exit()
    print(product)
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
s = list(set(l))
all_sum = 0
count = {}
for i in range(len(s)):
    v = l.count(s[i])
    all_sum += v * (v - 1) // 2
    count[s[i]] = v
for i in range(len(l)):
    if count[l[i]] > 1:
        v = count[l[i]]
        print(all_sum - v * (v-1) // 2 + (v-1) * (v-2)//2)
    else:
        print(all_sum)

### FIXED CODE ###

import collections

def count_defaultdict(it):
    counter = collections.defaultdict(int)
    for x in it:
        counter[x] += 1
    return dict(counter)

_ = int(input())
l = list(map(int, input().split()))
all_sum = 0
count = count_defaultdict(l)
for _, v in count.items():
    all_sum += v * (v - 1) // 2
for i in range(len(l)):
    if count[l[i]] > 1:
        v = count[l[i]]
        print(all_sum - v * (v-1) // 2 + (v-1) * (v-2)//2)
    else:
        print(all_sum)
### BUGGY CODE ###

def main():
  n,a,b = list(map(int,input().split()))
  blue=""
  red=""
  for i in range(0,a):
    blue+='b'
  for i in range(0,b):
    red+='r'
  ans=""
  while n>len(ans):
    ans+=blue
    ans+=red
  print(ans[:n].count('b'))
main()

### FIXED CODE ###

def main():
  n,a,b = list(map(int,input().split()))
  ans=0
  count=int(n/(a+b))
  ans+=count*a
  amari=n-count*(a+b)
  if amari <= a:
    ans+=amari
  else:
    ans+=a
  print(ans)
main()
### BUGGY CODE ###

from itertools import accumulate

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

def calc_imos(arr):
  imos=[0]*(N+1)
  for i,a in enumerate(arr):
    l=max(0,i-a) #照らす範囲の左側インデックス、0が最小
    r=min(N-1,i+a) #照らす範囲右側インデックス,arrの長さ-1=Nが最大
    imos[l]+=1
    imos[r+1]-=1
    #print("imos",imos)
  imos=list(accumulate(imos))
  #print("imos",imos)
  return imos[:-1]

for k in range(min(50,K)):
  A=calc_imos(A)
print(*A,sep=" ")

### FIXED CODE ###

from itertools import accumulate

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

def calc_imos(arr):
  imos=[0]*(N+1)
  for i,a in enumerate(arr):
    l=max(0,i-a) #照らす範囲の左側インデックス、0が最小
    r=min(N-1,i+a) #照らす範囲右側インデックス,arrの長さ-1=Nが最大
    imos[l]+=1
    imos[r+1]-=1
  imos=list(accumulate(imos))
  return imos[:-1]

for k in range(min(50,K)):
  A=calc_imos(A)
print(*A,sep=" ")
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(lambda x:int(x) - 1, input().split()))
res = list(range(N))
while K:
    if K & 1:
        res = [res[A[i]] for i in range(N)]
    A = [A[A[i]] for i in range(N)]
    K >>= 1
print(res[0] + 1)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(lambda x:int(x) - 1, input().split()))
res = list(range(N))
while K:
    if K & 1:
        res = [res[A[i]] for i in range(N)]
    A = [A[A[i]] for i in range(N)]
    K >>= 1
print(res[0] + 1)
### BUGGY CODE ###

N = int(input())
K = []

for i in range(N):
    value = str(input())
    if value in K:
        K.remove(value)
    else:
        K.append(value)

print(len(K))


### FIXED CODE ###

import collections

N = int(input())
M = [int(input()) for i in range(N)]

value = list(collections.Counter(M).values())

sum = 0
for i in value:
    sum += i%2

print(sum)
### BUGGY CODE ###

n = int(input())
ls = []
ls_re = []
for i in range(1,n+1):
    ls.append(i)
for i in reversed(ls):
    ls_re.append(i)

ans = 0
for i in range(n):
    ans += (ls[i]%ls_re[i])
    #print(ls[i]%ls_re[i],end=" ")

c = 0
for i in range(1,n):
    c += i
    
print(c)
    

### FIXED CODE ###

n = int(input())
c = 0    
an = (n-1)*n//2
print(round(an))
### BUGGY CODE ###

from copy import deepcopy
from math import ceil

N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]

A -= B  # 爆発は追加ダメージ扱いとする

# にぶたん
ok, ng = 10 ** 9, 0
while abs(ok - ng) > 1:
    X = (ok + ng) // 2

    h = deepcopy(H)
    h = [max(hi - B * X, 0) for hi in h]
    h = [ceil(hi / A) for hi in h]

    if sum(h) <= X:
        ok = X
    else:
        ng = X

print(ok)


### FIXED CODE ###

import math

N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]

add_damage = A-B
left = 1
right = 10**9
ans = float('inf')

for i in range(int(math.log(10**9, 2)+1)):
    T = (left+right) // 2
    h = H.copy()
    h = list(map(lambda x: max(0, x-T*B), h))
    h = list(map(lambda x: math.ceil(x / add_damage), h))
    need = sum(h)
    
    if need <= T:
        right = T
        ans = min(ans, T)
    else:
        left = T

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

import math
s = int(input())

root = math.floor(math.sqrt(s))

if s <= 10 ** 9:
  print(0,0,0,1,s,0)
else:
  for i in reversed(range(root+1)):
    if s % i == 0:
      print(0,0,0,i,s//i,0)
      break
  

### FIXED CODE ###

import math
s = int(input())

root = math.ceil(math.sqrt(s))

if s <= 10 ** 9:
  print(0,0,0,1,s,0)
else:
  tmp = root**2 - s
  print(0,0,tmp,root,root,1)
### BUGGY CODE ###

n,w=map(int,input().split())
weight=[]
value=[]
total=w
for i in range(n):
    x,y=map(int,input().split())
    weight.append(x)
    value.append(y)
l=len(weight)
dp=[[0]*(w+1) for j in range(l)]
for i in range(l):
    for w in range(total+1):
        if weight[i]<=w:
            dp[i][w]=max(value[i]+dp[i-1][w-weight[i]],dp[i-1][w])
        else:
            dp[i][w] = dp[i-1][w]
print(dp[l-1][total])

### FIXED CODE ###

import numba as nb
import sys
import numpy as np
@nb.njit
def solve(w,weight,value):
    total=w
    dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
    for i in range(l):
        for w in range(total+1):
            if weight[i]<=w:
                dp[i][w]=max(value[i]+dp[i-1][w-weight[i]],dp[i-1][w])
            else:
                dp[i][w] = dp[i-1][w]
    print(dp[l-1][total])
n,w=map(int,sys.stdin.readline().split())
weight=[0]*n
value=[0]*n
total=w
for i in range(n):
    x,y=map(int,sys.stdin.readline().split())
    weight[i]=x
    value[i]=y
l=len(weight)
solve(w,weight,value)
### BUGGY CODE ###

s = (input()[::-1]) # 入力文字列を逆順でsに格納
n = len(s)
counts = [0]*2019
counts[0]=1
b = 1
num = 0
for i in range(n):
    num += int(s[i])*b
    num %=2019
    b *=10
    b %2019
    counts[num]+=1

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
# print(counts)
ans = 0
for j in counts:
    ans +=j*(j-1)/2


print(int(ans))

### FIXED CODE ###

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
### BUGGY CODE ###

from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
Q=int(input())
v=[0 for i in range(Q)]
d=[0 for i in range(Q)]
c=[0 for i in range(Q)]
for i in range(Q):
    v[i],d[i],c[i]=map(int,input().split());v[i]-=1
q=deque()
ans=[0 for i in range(N)]
for t in range(Q)[::-1]:
    reached=[0 for i in range(N)]
    q.append((v[t],d[t]))
    while(q):
        x,l=q.popleft()
        reached[x]=1
        if ans[x]==0:
            ans[x]=c[t]
        if l==0:
            continue
        for y in G[x]:
            if reached[y]==0:
                q.append((y,l-1))
for line in ans:
    print(line)


### FIXED CODE ###

from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
Q=int(input())
v=[0 for i in range(Q)]
d=[0 for i in range(Q)]
c=[0 for i in range(Q)]
for i in range(Q):
    v[-i-1],d[-i-1],c[-i-1]=map(int,input().split());v[-i-1]-=1
q=deque()
color=[0 for i in range(N)]
dp=[-1 for i in range(N)]
for t in range(Q):
    if dp[v[t]]>=d[t]:
        continue
    dp[v[t]]=d[t]
    q.append((v[t],d[t]))
    while(q):
        vv,dd=q.popleft()
        if color[vv]==0:
            color[vv]=c[t]
        dd-=1
        for y in G[vv]:
            if dp[y]>=dd:
                continue
            dp[y]=dd
            q.append((y,dd))
for line in color:
    print(line)
### BUGGY CODE ###

L, R = map(int, input().split())
ans = 2018
for i in range(L, R+1):
    for j in range(i + 1, R+1):
        tmp = i * j % 2019
        if tmp < ans:
            ans = tmp
print(ans)

### FIXED CODE ###

L, R = map(int, input().split())
ans = 0

if L // 2019 < R // 2019:
    print(ans)
    exit()

ans = 2018
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp
print(ans)
### BUGGY CODE ###

import math
def q77(N, a):
    i = 0
    while True:
        b = False
        for j in range(N):
            a[j] = a[j]/2
            if a[j].is_integer():
                i += 1
                b = True
                break
        if not b:
            break
    return i

N = int(input())
a = [int(i) for i in input().split()]

print(q77(N, a))

### FIXED CODE ###

import math
def q77(N, a):
    i = 0
    o = 0
    while True:
        b = False
        for j in range(o, N):
            a[j] = a[j]/2
            if a[j].is_integer():
                i += 1
                b = True
                break
            else:
                o = j
        if not b:
            break
    return i

N = int(input())
a = [int(i) for i in input().split()]

print(q77(N, a))
### BUGGY CODE ###

def DP():
    N, W = map(int, input().split())
    wv = [[int(i) for i in input().split()] for i in range(N)]

    dp=[[0]*(W+1) for i in range(N+1)]

    for w in range(W+1):
        for n in range(N):
            if wv[n][0] <= w:
                dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
            else:
                dp[n+1][w] = dp[n][w]
    return dp[N][W]


print(DP())

### FIXED CODE ###

N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for i in range(N)]
 
dp=[[0]*(W+1) for i in range(N+1)]
 
for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]
 
 
print(dp[N][W])
### BUGGY CODE ###

n = int(input())
s = input()
ans = s[1:].count('E')
for i in range(1,len(s)-1):
    ans = min(ans,s[:i].count('W')+s[i+1:].count('E'))
ans = min(ans,s[:len(s)].count('W'))
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
w = [0]
e = [0]
for i in range(len(s)):
    if s[i]=="W":
        w.append(w[i]+1)
        e.append(e[i])
    else:
        w.append(w[i])
        e.append(e[i]+1)
ans = 10**9
for i in range(0,len(s)):
    ans = min(ans,w[i]+e[-1]-e[i+1])
print(ans)
### BUGGY CODE ###

import os

def main():
        n = int(input())
        a_list = list(map(int, input().split()))
        result = [0]*n
        list_set = set(a_list)
        for i in list_set:
                result[i-1] = a_list.count(i)
        for i in result:
                print(i)

if __name__ == "__main__":
        main()

### FIXED CODE ###

import os

def main():
	n = int(input())
	a_list = list(map(int, input().split()))
	result = [0]*n
	for i in a_list:
		result[i-1] += 1
	for i in result:
		print(i)

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

n = int(input())
a = [[] for i in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))
    for j in range(n-1):
        a[i][j] -= 1
    a[i].reverse()
q = []

def check(i):
    if len(a[i]) == 0:
        return 
    j = a[i][-1]
    if len(a[j]) == 0:
        return
    if a[j][-1] == i:
        q.append([min(i,j), max(i,j)])
for i in range(n):
    check(i)
day = 0
while (len(q) > 0):
    day += 1
    prevQ = list(map(list, set(map(tuple, q))))
    q = []
    for i,j in prevQ:
        a[i].pop()
        a[j].pop()
        check(i)
        check(j)
for i in range(n):
    if len(a[i]) > 0:
        print(-1)
        exit()
print(day)

### FIXED CODE ###

n = int(input())
a = [[] for i in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))
    for j in range(n-1):
        a[i][j] -= 1
    a[i].reverse()
q = []

def check(i):
    if len(a[i]) == 0:
        return 
    j = a[i][-1]
    if len(a[j]) == 0:
        return
    if a[j][-1] == i:
        q.append([min(i,j), max(i,j)])
for i in range(n):
    check(i)
day = 0
while (len(q) > 0):
    day += 1
    prevQ = list(map(list, set(map(tuple, q))))
    q = []
    for i,j in prevQ:
        a[i].pop()
        a[j].pop()
        check(i)
        check(j)
for i in range(n):
    if len(a[i]) > 0:
        print(-1)
        exit()
print(day)