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

from collections import deque
import numpy as np
h, w = map(int, input().split())
mass = [input() for _ in range(h)]

dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]


def bfs(s, t):
    if mass[s][t] == "#":
        return 0
    visited = np.zeros((h, w))
    depth = np.zeros((h, w))
    q = deque([[s, t]])
    while q:
        x, y = q.popleft()
        visited[x][y] += 1
        r = depth[x][y] + 1
        for d in range(4):
            nx = x + dx[d]
            ny = y + dy[d]
            if nx < 0 or h - 1 < nx:
                continue
            if ny < 0 or w - 1 < ny:
                continue

            if mass[nx][ny] == "#":
                continue
            if visited[nx][ny]:
                continue

            q.append([nx, ny])
            depth[nx][ny] = r
    return np.max(depth)


ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, bfs(i, j))
print(int(ans))



### FIXED CODE ###

import numpy as np
from collections import deque
h, w = map(int, input().split())
r = [list(input()) for i in range(h)]


def dist(s, t):
    if r[s][t] == "#":
        return 0
    else:
        visited = np.zeros((h, w))
        visited[s][t] += 1
        distance = np.zeros((h, w))
        q = deque([[s, t]])
        while len(q) > 0:
            i, j = q.popleft()
            d = distance[i][j] + 1
            if j != w-1:
                if r[i][j+1] == "." and not visited[i][j+1]:
                    q.append([i, j + 1])
                    visited[i][j+1] += 1
                    distance[i][j+1] += d
            if j != 0:
                if r[i][j-1] == "." and not visited[i][j-1]:
                    q.append([i, j - 1])
                    visited[i][j - 1] += 1
                    distance[i][j - 1] += d
            if i != 0:
                if r[i-1][j] == "." and not visited[i-1][j]:
                    q.append([i - 1, j])
                    visited[i-1][j] += 1
                    distance[i-1][j] += d
            if i != h-1:
                if r[i+1][j] == "." and not visited[i+1][j]:
                    q.append([i + 1, j])
                    visited[i+1][j] += 1
                    distance[i+1][j] += d
        return np.max(distance)


ans = 0
for s in range(h):
    for t in range(w):
        ans = max(ans, dist(s, t))

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

import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


r,g,b,n=l()
ans=0
for i in range(n//r+1):
    for j in range(n//g+1):
        k=n-i*r-j*g
        if(k>=0 and k%b==0):
            ans+=1
print(ans)

### FIXED CODE ###


r,g,b,n=map(int,input().split())
ans=0
r,g,b=sorted([r,g,b])[::-1]
for i in range(n//r+1):
    for j in range(n//g+1):
        k=n-i*r-j*g
        if(k<0):
            break
        if(k>=0 and k%b==0):
            ans+=1
print(ans)
### BUGGY CODE ###

k, s = map(int, input().split())
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        if s - x - y > k:
            continue
        elif s - x - y < 0:
            continue
        z = s - x - y 
        if 0 <= z <= k:
            cnt += 1
print(cnt)


### FIXED CODE ###

k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(max(s - x - k, 0), min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        else:
            continue
print(cnt)
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
mod = 2*K
field = np.zeros((2*K+1, 2*K+1), dtype='i')


def gen_pattern(x):
    if x < K-1:
        return [[0, x+1], [x+K+1, 2*K]]
    else:
        return [[x-K+1, x+1]]

for _ in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'W':
        y += K
    x %= mod
    y %= mod
    for tmp in [0, K]:
        for l, r in gen_pattern((x+tmp) % mod):
            for b, t in gen_pattern((y+tmp) % mod):
                field[l][b] += 1
                field[l][t] -= 1
                field[r][b] -= 1
                field[r][t] += 1

ans = np.max(np.cumsum(np.cumsum(field, axis=0), axis=1))
print(ans)


### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
mod = 2*K
#field = np.zeros((2*K+1, 2*K+1), dtype='i')
field = [[0]*(2*K+1) for _ in range(2*K+1)]

def gen_pattern(x):
    if x < K-1:
        return [[0, x+1], [x+K+1, 2*K]]
    else:
        return [[x-K+1, x+1]]

for _ in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'W':
        y += K
    x %= mod
    y %= mod
    for tmp in [0, K]:
        for l, r in gen_pattern((x+tmp) % mod):
            for b, t in gen_pattern((y+tmp) % mod):
                field[l][b] += 1
                field[l][t] -= 1
                field[r][b] -= 1
                field[r][t] += 1

field = np.array(field)
print(field.cumsum(axis=0).cumsum(axis=1).max())
### BUGGY CODE ###

import queue

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

def main():
    H,W = ints_raw()
    DFST = [[-1 for i in range(W)]for i in range(H)]
    qu = queue.Queue()
    dirs = [[1,0,1],[0,1,1],[-1,0,1],[0,-1,1]]
    ans = 0
    for h in range(H):
        S = input()
        for w in range(W):
            if S[w]=="#":
                DFST[h][w]=0
                qu.put([h,w,0])
    while not qu.empty():
        cpos = qu.get()
        for dir in dirs:
            
            ny,nx,nt = [cpos[0]+dir[0],cpos[1]+dir[1],cpos[2]+dir[2]]
            if ny<0 or ny>=H or nx<0 or nx>=W:
                continue
            if DFST[ny][nx]!=-1:
                continue
            DFST[ny][nx]=nt
            ans = max(ans,nt)
            qu.put([ny,nx,nt])
    return ans

print(main())


### FIXED CODE ###

from collections import deque

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

def main():
    H,W = ints_raw()
    DFST = [[-1 for i in range(W)]for i in range(H)]
    qu = deque()
    dirs = [[1,0,1],[0,1,1],[-1,0,1],[0,-1,1]]
    ans = 0
    for h in range(H):
        S = input()
        for w in range(W):
            if S[w]=="#":
                DFST[h][w]=0
                qu.append([h,w,0])
    while len(qu)!=0:
        cpos = qu.popleft()
        for dir in dirs:
            
            ny,nx,nt = [cpos[0]+dir[0],cpos[1]+dir[1],cpos[2]+dir[2]]
            if ny<0 or ny>=H or nx<0 or nx>=W:
                continue
            if DFST[ny][nx]!=-1:
                continue
            DFST[ny][nx]=nt
            ans = max(ans,nt)
            qu.append([ny,nx,nt])
    return ans

print(main())
### BUGGY CODE ###

n,k,q = (int(i) for i in input().split())  
a = []
for i in range(q):
    a.append(int(input()))

score = [k for _ in range(n)]

for i in range(len(a)):
    clear_num = a[i]-1
    for j in range(n):
        if j != clear_num:
             score[j] += -1

for j in range(n):
    if score[j] > 0:
        print('Yes')
    else:
        print('No')



### FIXED CODE ###

n,k,q = (int(i) for i in input().split())  
a = []
for i in range(q):
    a.append(int(input()))

score = [0 for _ in range(n)]

for i in range(len(a)):
    clear_num = a[i]-1
    score[clear_num] += 1


for j in range(n):
    if k + score[j] - q > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

def powl(x, n, l):#繰り返し2乗法 O(log n)
    ans = 1
    while n > 0:
        if bin(n & 1) == bin(1):
            ans = ans*x
        x = (x*x)%l
        n = n >> 1 #ビットシフト
    return ans

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

out=powl(2,n,pow(10,9)+7)-1
X,Y=1,1
for i in range(a):
    X=X*(i+1)
    Y=Y*(n-i)
out-=Y*powl(X,pow(10,9)+5,pow(10,9)+7)

for i in range(a,b):
    X=X*(i+1)
    Y=Y*(n-i)
out-=Y*powl(X,pow(10,9)+5,pow(10,9)+7)

print(out%(pow(10,9)+7))

### FIXED CODE ###

def powl(x, n, l):#繰り返し2乗法 O(log n)
    ans = 1
    while n > 0:
        if bin(n & 1) == bin(1):
            ans = ans*x
        x = (x*x)%l
        n = n >> 1 #ビットシフト
    return ans

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

out=powl(2,n,pow(10,9)+7)-1
X,Y=1,1
for i in range(a):
    X=(X*(i+1))%(pow(10,9)+7)
    Y=(Y*(n-i))%(pow(10,9)+7)
out-=Y*powl(X,pow(10,9)+5,pow(10,9)+7)

for i in range(a,b):
    X=(X*(i+1))%(pow(10,9)+7)
    Y=(Y*(n-i))%(pow(10,9)+7)
out-=Y*powl(X,pow(10,9)+5,pow(10,9)+7)

print(out%(pow(10,9)+7))
### BUGGY CODE ###

n = 50001
is_prime = [True for i in range(n)]
is_prime[0] = is_prime[1] = False
i = 2
while i**2 <= n:
    j = i*2
    while j < n:
        is_prime[j] = False
        j += i
    i += 1

cnt_pair = [0 for i in range(n)]
for i in range(n):
    cnt = 0
    if i%2 == 0:
        for j in range(0, n//2):
            if is_prime[j] and is_prime[n - j]:
                cnt += 1
        cnt_pair[i] = cnt

while True:
    n = int(input())
    if n == 0:
        break
    print(cnt_pair[n])



### FIXED CODE ###

n = 50001
is_prime = [i for i in range(n)]
is_prime[0] = is_prime[1] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j < n:
        is_prime[j] = 0
        j += i
    i += 1

prime_set  = set(is_prime)
prime_set.remove(0)
prime_list = sorted(list(prime_set))

while True:
    cnt = 0
    n = int(input())
    if n == 0:
        break
    for i in prime_list:
        if i > n//2:
            break
        if n - i in prime_set:
            cnt += 1
    print(cnt)
### BUGGY CODE ###

N,M=map(int,input().split())
inf=10**18
dp=[inf for _ in range(2**N)]
dp[0]=0;AB=[];C=[]
for _ in range(M):
    AB.append(tuple(map(int,input().split())))
    C.append(tuple(map(int,input().split())))
for ab,c in zip(AB,C):
    for v in range(2**N):
        nv=int(v)
        for k in c:
            bi=2**(k-1)
            if (v//bi)%2==0:
                nv+=bi
        dp[nv]=min(dp[nv],dp[v]+ab[0])
if dp[-1]==inf:
    print(-1)
else:
    print(dp[-1])

### FIXED CODE ###

N,M=map(int,input().split())
dp=[float("inf") for _ in range(2**N)]
dp[0]=0
for _ in range(M):
    a,b=map(int,input().split())
    c=sum([2**(int(i)-1) for i in input().split()])
    for v in range(2**N):
        nv=v|c
        dp[nv]=min(dp[nv],dp[v]+a)
if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1])
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
    A.append(int(input()))

point = [K] * N

def mainasu(n):
    return n-1

for i in range(Q):
    point = list(map(mainasu, point))
    point[A[i] - 1] += 1

for j in range(N):
    if point[j] > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
    A.append(int(input()))

point = [K-Q] * N

for i in range(Q):
    point[A[i] - 1] += 1

for j in range(N):
    if point[j] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

k, s = map(int, input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        for u in range(k+1):
            if (i + j + u) == s:
                count += 1
print(count)

### FIXED CODE ###

k,s=list(map(int,input().split()))
o=0
for i in range(k+1):
    for u in range(k+1):
        if 0<=(s-i-u)<=k:
            o+=1
print(o)
### BUGGY CODE ###

N=int(input())
S=input()
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (j-i!=k-j) and (S[i]!=S[j]) and (S[j]!=S[k]) and (S[i]!=S[k]):
                ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
S=input()

r,g,b=0,0,0
for s in S:
    if s=='R': r+=1
    elif s=='G': g+=1
    else: b+=1


ng=0
for i in range(N):
    for j in range(i+1,N):
        k=j+(j-i)
        if k>=N: continue
        if S[i]!=S[j] and S[j]!=S[k] and S[i]!=S[k]:
            ng+=1

ans=r*g*b
print(ans-ng)
### BUGGY CODE ###

n,m =(int(i) for i in input().split())
x = list(int(i) for i in input().split())
x.sort()
sa = []
ans = 0
if m <= n:
  print('0')
  exit()
for i in range(m-1):
  sa.append(x[i+1]-x[i])
for i in range(n-1):
  tmp1 = max(sa)
  sa.remove(tmp1)

ans = sum(sa)
print(ans)

### FIXED CODE ###

n,m =(int(i) for i in input().split())
x = list(int(i) for i in input().split())
x.sort()
sa = []
ans = 0
if m <= n:
  print('0')
  exit()
for i in range(m-1):
  sa.append(x[i+1]-x[i])
s2 = sorted(sa,reverse = True)
#print(s2)
for i in range(n-1,len(s2)):
  ans += s2[i]
print(ans)
### BUGGY CODE ###

inp = list(map(int, input().split(" ")))
N, K = inp[0], inp[1]
h_arr = list(map(int, input().split(" ")))
dp = [0]*N

for i in range(1, N):
	dp[i] = min([abs(h_arr[i]-h_arr[j]) + dp[j] for j in range(max(i-K, 0), i)])
print(dp[-1])

### FIXED CODE ###

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])
### BUGGY CODE ###

import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
G = [[] for _ in range(N)]
ans = {}
queue = deque([])
e = []
for l in range(N-1):
    temp = list(map(int,input().split()))
    temp[0] -= 1
    temp[1] -= 1
    e.append(tuple(temp))
    ans[(temp[0],temp[1])] = 0
    ans[(temp[1],temp[0])] = 0
    G[temp[0]].append(temp[1])
    G[temp[1]].append(temp[0])
    if l == 0:
        queue.append(temp[0])
#使えない色
nuc = [[0] for _ in range(N)]
#使った色
auc = []
#答え
def bfs(x):
    k = 1
    for i in G[x]:
        if ans[(x,i)] ==0:
            queue.append(i)
            flag = 1
            while flag:
                if k not in nuc[x]:         
                    ans[(x,i)] = k
                    ans[(i,x)] = k
                    nuc[x].append(k)
                    nuc[i].append(k)
                    if k not in auc:
                        auc.append(k)
                    flag = 0
                else:
                    k += 1
                
while len(queue) > 0:
    next_ = queue.popleft()
    bfs(next_)
print(len(auc))
for m in e:
    print(ans[m])


### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
G = [[] for _ in range(N)]
ans = {}
queue = deque([])
e = []
for l in range(N-1):
    temp = list(map(int,input().split()))
    temp[0] -= 1
    temp[1] -= 1
    e.append(tuple(temp))
    ans[(temp[0],temp[1])] = 0
    ans[(temp[1],temp[0])] = 0
    G[temp[0]].append(temp[1])
    G[temp[1]].append(temp[0])
    if l == 0:
        queue.append(temp[0])
#使えない色
nuc = [[0] for _ in range(N)]
#使った色
auc = []
#答え
def bfs(x):
    k = 1
    for i in G[x]:
        if ans[(x,i)] ==0:
            queue.append(i)
            flag = 1
            while flag:
                if k not in nuc[x]:         
                    ans[(x,i)] = k
                    ans[(i,x)] = k
                    nuc[x].append(k)
                    nuc[i].append(k)
                    if k not in auc:
                        auc.append(k)
                    flag = 0
                else:
                    k += 1
                
while len(queue) > 0:
    next_ = queue.popleft()
    bfs(next_)
print(len(auc))
for m in e:
    print(ans[m])
### BUGGY CODE ###

def shift_only(array):
    tmp = []
    counter = 0
    while True:
        flag = True
        # 全て偶数かを確認
        for num in array:
            if num%2 != 0:
                flag = False
        if flag == False:
            break
        array = [i/2 for i in array]
        counter +=1
    print(counter)
    
inp = list(map(int, input().split()))
n = inp[0]
array = inp[1:]
shift_only(array)

### FIXED CODE ###

def shift_only(array):
    tmp = []
    counter = 0
    while True:
        flag = True
        # 全て偶数かを確認
        for num in array:
            if num%2 != 0:
                flag = False
        if flag == False:
            break
        array = [i/2 for i in array]
        counter +=1
    print(counter)
    
n = int(input())
a = list(map(int, input().split()))
shift_only(a)
### BUGGY CODE ###

x = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


p = factorization(x)
# print(p)
Bas = 0
Aas = 0
for i in range(1):
    _p = p[i][0]
    # print(_p)
    B = 0
    while True:

        xnew_p = (B + _p)**5 - B ** 5
        xnew_n = (-1*B + _p)**5 - (-1*B) ** 5
        # print(B, xnew_p, xnew_n)
        if xnew_n == x:
            # print('?')
            Bas = -1*B
            Aas = -B + _p
            break

        if xnew_p == x:
            # print('!')
            Bas = B
            Aas = + _p
            break
        B += 1

print(f'{Aas} {Bas}')


### FIXED CODE ###

x = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


p = factorization(x)
p = make_divisors(x)
# print(p)
Bas = 0
Aas = 0

flg = False
# p.append([1, 1])
# print(p)
for i in range(len(p)):
    if flg:
        break
    _p = p[i]
    # print(_p)
    B = int(-_p/2)

    while True:

        xnew = (B + _p)**5 - B ** 5
        # print(B, xnew)
        if xnew == x:
            Bas = B
            Aas = B + _p
            flg = True
            break

        if xnew > x:
            break

        B += 1


print(f'{Aas} {Bas}')
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
# import numpy as np


def main():
    N = int(input())
    P = list(map(int, input().split()))

    count = 0
    for i in range(N):
        Q = sorted(P[:i+1], reverse=True)
        # print(i+1, Q)
        if Q[-1] == P[i]:
            count += 1
    print(count)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
# import numpy as np


def main():
    N = int(input())
    P = list(map(int, input().split()))

    count = 0
    min_P = 200000
    for i in range(N):
        if min_P > P[i]:
            min_P = P[i]
        if min_P == P[i]:
            count += 1
    print(count)

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

import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    # emp:0 male:1 female:2
    N = int(input())
    L = [-1] * N

    i = 0
    print(i, flush=True)
    s = str(input())
    if s == 'Vacant':
        sys.exit()
    elif s == 'Male':
        L[i] = 1
    else:
        L[i] = 2

    i = N // 2
    print(i, flush=True)
    s = str(input())
    if s == 'Vacant':
        sys.exit()
    elif s == 'Male':
        L[i] = 1
    else:
        L[i] = 2

    # リストAをとってkeyのある添字を返す
    # なかったら-1
    def bin_search(pl, pr):

        while pl <= pr:
            pc = (pl + pr) // 2
            print(pc, flush=True)

            s = str(input())
            if s == 'Vacant':
                sys.exit()
            elif s == 'Male':
                L[pc] = 1
            else:
                L[pc] = 2

            if abs(L[pr] - L[pc]) == 0 and (pr - pc) % 2 == 1:
                pr = pc - 1
            else:
                pl = pc + 1

    if abs(L[N // 2] - L[0]) == 0 and (N // 2 % 2 == 1):
        bin_search(0, N // 2)
    else:
        bin_search(N // 2 + 1, N - 1)


resolve()

### FIXED CODE ###

N = int(input())


def query(i):
    print(i)
    s = input()
    if s == 'Vacant':
        exit()
    return s


root = query(0)


def is_ok(ind):
    # 左ならTrue
    response = query(ind)
    if ind % 2 == 1:
        return root == response
    else:
        return root != response


def bin_search_meguru():
    """
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng, okは,とり得る最小の値-1,とり得る最大の値+1
    """

    # 適当にいじる
    ng = -1  # ind=0が条件を満たすこともあるため
    ok = N  # ind=len(a)-1が条件を満たさないこともあるため

    # いじらない
    # okとngのどちらが大きいかわからないことを考慮
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return False


bin_search_meguru()
### BUGGY CODE ###

import collections 

N = int(input())
A = list(map(int, input().split()))
lst = []
c = collections.Counter(A)
for key in c:
    lst.append(key)
lst.sort()
cnt = 0
for i in range(1, N+1):
    if(i in lst):
        print(c[i])
    else:
        print(0)

### FIXED CODE ###

import collections 

N = int(input())
A = list(map(int, input().split()))
lst = set()
c = collections.Counter(A)
cnt = 0
for i in range(1, N+1):
    if(c[i] != 0):
        print(c[i])
    else:
        print(0)
### BUGGY CODE ###

N, M = map(int, input().split())
l_1 = [[] for i in range(N+1)]
l_2 = []
for i in range(M):
  p, y = map(int, input().split())
  l_1[p].append(y)
  l_2.append([p, y])
  
for i in range(N+1):
  if l_1[i] != []:
    l = sorted(l_1[i])
    l_1[i] = l
    
for i in range(M):
  c = l_2[i]
  n = l_1[c[0]].index(c[1]) + 1
  ans = str(c[0]).zfill(6) + str(n).zfill(6)
  print(ans)

### FIXED CODE ###

import bisect
N, M = map(int, input().split())
l_1 = [[] for i in range(N+1)]
l_2 = []
for i in range(M):
  p, y = map(int, input().split())
  l_1[p].append(y)
  l_2.append([p, y])
  
for i in range(N+1):
  l_1[i].sort()
    
for i in range(M):
  c = l_2[i]
  n = bisect.bisect_left(l_1[c[0]], c[1]) + 1
  ans = str(c[0]).zfill(6) + str(n).zfill(6)
  print(ans)
### BUGGY CODE ###

n = int(input())
s = list(map(int, input().split()))
count = 0
cl = []
sm = 0
for i in range(n):
  sm+=s[i]
  cl.append(sm)

        
m = set(cl)
st = set(cl)
for x in st:
  t = cl.count(x)
  count+=int(t*(t-1)/2)

count+=cl.count(0)
print(count)

### FIXED CODE ###

n = int(input())
s = list(map(int, input().split()))
count = 0
dic = {}
cl = []
sm = 0
for i in range(n):
  sm+=s[i]
  if sm not in dic.keys():
    dic.update({sm:1})
  else:
    dic[sm]+=1

        
for x in dic.keys():
  t = dic[x]
  if x==0:
    count+=dic[x]
  count+=int(t*(t-1)/2)

print(count)