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

n = int(input())
list = [int(e) for e in input().split()]
set = set(list)

for i in range(1,n+1):
    if i in set:
        print(list.count(i))
        del list[0:list.count(i)]
        set.remove(i)
    else:
        print(0)

### FIXED CODE ###

n = int(input())
list = [int(e) for e in input().split()]

import collections
list2 = collections.Counter(list)

for i in range(1,n+1):
    print(list2[i])
### BUGGY CODE ###

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

sum_list = [None] * (N+1)

sum_list[0] = 0
for i in range(N):
    sum_list[i+1] = sum_list[i] + A[i]

output = 0
for i in range(N+1):
    for j in range(i+1, N+1):
        if sum_list[j] - sum_list[i] == 0:
            # print("(", str(i), ",", str(j), ")")
            output += 1

print(output)

### FIXED CODE ###

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

sum_list = [None] * (N+1)

sum_list[0] = 0
for i in range(N):
    sum_list[i+1] = sum_list[i] + A[i]

output = 0
sum_list_sorted = sorted(sum_list)
i = 0
while i < N:
    k = 1
    for j in range(i+1, N+1):
        if sum_list_sorted[i] == sum_list_sorted[j]:
            k += 1
        else:
            break
    output += k * (k-1) // 2
    i += k
    
print(output)
### BUGGY CODE ###

n = int(input())
m = 0
for i in range(n-1):
    m += (i+1)
print(m)


### FIXED CODE ###

n = int(input())
m = (n-1)*n//2
print(m)
### BUGGY CODE ###

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

A_sum = [0]
a_sum = 0
for a in A:
    a_sum += a
    A_sum.append(a_sum)

B_sum = [0]
b_sum = 0
for b in B:
    b_sum += b
    B_sum.append(b_sum)

max_count = 0
for i in range(N+1):
    j = M
    if A_sum[i] > K:
        break

    while B_sum[j] + A_sum[i] > K:
        j -= 1
    max_count = max(max_count, i + j)
print(max_count)

### FIXED CODE ###

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

A_sum = [0]
for i in range(N):
    A_sum.append(A[i]+A_sum[i])

B_sum = [0]
for i in range(M):
    B_sum.append(B[i]+B_sum[i])

max_count = 0
j = M
for i in range(N+1):
    if A_sum[i] > K:
        break

    while B_sum[j] + A_sum[i] > K:
        j -= 1
    max_count = max(max_count, i + j)
print(max_count)
### BUGGY CODE ###

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

#よくある補間だとiごとにO(p)次多項式をx-j倍する操作が入ってO(p**3),間に合わない

#editorial
#1-(x-j)**(p-1)

ans = [0 for _ in range(p)]

chs = [1]

deno = 1
nume = 1

for i in range(1,p):
    nume*=p-i
    deno *= pow(i,p-2,p)
    chs.append(nume*deno)

for i in range(p):
    if not a[i]:
        continue
    for j in range(p):
        ans[j] -= chs[j]*pow(p-i,p-j-1,p)
    ans[0]+=1
    

for i in range(p):
    ans[i]%=p 


print(*ans)
    

### FIXED CODE ###

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

#よくある補間だとiごとにO(p)次多項式をx-j倍する操作が入ってO(p**3),間に合わない

#editorial
#1-(x-j)**(p-1)

ans = [0 for _ in range(p)]

chs = [1]

deno = 1
nume = 1

for i in range(1,p):
    nume*=p-i
    deno *= pow(i,p-2,p)
    chs.append(nume*deno%p)

#pow使っていたの修正
for i in range(p):
    tmp = 1
    if not a[i]:
        continue
    for j in range(p):
        ans[p-1-j] -= chs[p-1-j]*tmp
        tmp *= p-i
        tmp %= p
    ans[0]+=1
    

for i in range(p):
    ans[i]%=p 


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

import time
t=time.time()
from heapq import*
h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[list("#"+input()+"#") for x in range(h)]+[["#"]*(w+2)]

stack=[]
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x]=="#":
            grid[y][x]=0
            heappush(stack,(y,x))

for i in range(h*w):
    tmp=[]
    for my,mx in stack:
        for y,x in ([0,1],[1,0],[-1,0],[0,-1]):
            if grid[my+y][mx+x]==".":
                grid[my+y][mx+x]=i+1
                heappush(tmp,[my+y,mx+x])
    if time.time()-t>0.9:
        print(max(max(i[1:-1])for i in grid[1:-1]))
        exit()
    if all(all(j!="." for j in i)for i in grid):
        print(max(max(i[1:-1])for i in grid[1:-1]))
        exit()
    stack=tmp

### FIXED CODE ###

from heapq import*
h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[list("#"+input()+"#")for x in range(h)]+[["#"]*(w+2)]

stack=[]
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x]=="#":
            grid[y][x]=0
            stack.append((y,x))

for i in range(h*w):
    tmp=[]
    for my,mx in stack:
        for y,x in ([0,1],[1,0],[-1,0],[0,-1]):
            if grid[my+y][mx+x]==".":
                grid[my+y][mx+x]=i+1
                tmp.append([my+y,mx+x])
    stack=tmp
    if len(tmp)==0:
        print(i)
        break
### BUGGY CODE ###

# YouTube解説の方法（deque使わない）
from bisect import bisect_left
import sys
input = sys.stdin.readline

def bisect_right_reverse(L, target):
    return len(L) - bisect_left(L[::-1], target)

N = int(input())
A = [int(input()) for _ in range(N)]

L = []
for i in range(N):
    k = bisect_right_reverse(L, A[i])
    if k == len(L):
        L.append(A[i])
    else:
        L[k] = A[i]

print(len(L))

### FIXED CODE ###

from collections import deque
from bisect import bisect_left
N = int(input())
A = [int(input()) for _ in range(N)]
que = deque()
for i in range(N):
    k = bisect_left(que, A[i])
    if k == 0:
        que.appendleft(A[i])
    else:
        que[k - 1] = A[i]

print(len(que))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans=ans*i
    
if ans>1000000000000000000:
        print(-1)
        exit()
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 1
for i in a:
    ans=ans*i
    if ans>1000000000000000000:
        print(-1)
        exit()
    

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


N, X, Y = map(int, input().split())
dic = {key: 0 for key in range(1, N)}
for i in range(1, N+1):
    for j in range(1, N+1):
        if(i < j):
            key = min(abs(j - i), abs(X - i)+1+abs(j - Y),
                      abs(Y - i) + 1 + abs(j - X))
            dic[key] += 1
for ans in dic.values():
    print(ans)


### FIXED CODE ###


N, X, Y = map(int, input().split())
dic = {key: 0 for key in range(1, N)}
for i in range(1, N+1):
    for j in range(1, N+1):
        if(i < j):
            key = min(abs(j - i), abs(X - i)+1+abs(j - Y),
                      abs(Y - i) + 1 + abs(j - X))
            dic[key] += 1
for ans in dic.values():
    print(ans)
### BUGGY CODE ###

K,S = map(int, input().split())

ans = 0
for x in range(K+1):
    max_y = S - x if S - x < K else K
    for y in range(max_y + 1): 
        max_z = S - x - y if S - x -y < K else K
        for z in range(max_z + 1):
            if (x + y + z) == S:
                ans += 1
print(ans)


### FIXED CODE ###

K,S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K + 1): 
        z = S - x - y 
        if 0 <= z and z <= K:
            ans += 1
print(ans)
### BUGGY CODE ###

import re
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations, product

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    A = il()
    ans = 0
    for n in combinations(A, N - 1):
        ans = max(ans, reduce(gcd, n))
    return ans


if __name__ == "__main__":
    print(solve())


### FIXED CODE ###

import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    A = il()
    b = [0] * N
    c = [0] * N
    for i in range(1, N):
        b[i] = gcd(b[i - 1], A[i - 1])
    for i in range(N - 1)[::-1]:
        c[i] = gcd(c[i + 1], A[i + 1])
    d = [gcd(b[i], c[i]) for i in range(N)]
    return max(d)


if __name__ == "__main__":
    print(solve())
### BUGGY CODE ###

import math



N=int(input())

for i in range(1,N+1):
    ans=0
    if i<=5:
        print(0)
    else:
        ma=int(math.sqrt(i))
        mi=max(1,int(math.sqrt(i)/6))
        for x in range(mi,ma):
            for y in range(x,ma):
                for z in range(y,ma):
                    if x**2+y**2+z**2+x*y+y*z+z*x==i:
                        if x==y and y==z:
                            ans+=1
                        elif x==y or y==z or z==x:
                            ans+=3
                        else:
                            ans+=6
            
        print(ans)



### FIXED CODE ###

import math




N=int(input())

anslist=[0]*(N+1)
ma=int(math.sqrt(N))+1
for x in range(1,ma):
    for y in range(x,ma):
        for z in range(y,ma):
            n=x**2+y**2+z**2+x*y+y*z+z*x
            if n <=N:
                if x==y and y==z:
                    anslist[n]+=1
                elif x==y or y==z or z==x:
                    anslist[n]+=3
                else:
                    anslist[n]+=6

            
for i in range(1,N+1):
    print(anslist[i])
### BUGGY CODE ###

S = str(input())
x = len(S)
while '01' in S:
  S = S.replace('01', '')
while '10' in S:
  S = S.replace('01', '')
y = len(S)
print(x-y)

### FIXED CODE ###

S = str(input())
x = len(S)
if '0' in S:
  y0 = S.count('0')
else:
  y0 = 0
if '1' in S:
  y1 = S.count('1')
else:
  y1 = 0
  
d = abs(y0 - y1)
print(x - d)
### BUGGY CODE ###

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

### FIXED CODE ###

K, S = map(int, input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        if S - i - j <= K and S - i - j >= 0:
          count += 1        
print(count)
### BUGGY CODE ###


h,w=map(int,input().split())

field=[]
m=[]
INF=10**6

for i in range(h):
    row=list(input())
    field.append(row)
    m.append([INF for i in range(w)])

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

queue=[]
for i in range(h):
    for j in range(w):
        if field[i][j]=="#":
            m[i][j]=0
            queue.append([i,j])

while len(queue)>0:
    y,x=queue.pop(0)
    for k in range(4):
        nx=x+dx[k]
        ny=y+dy[k]
        if 0<=ny<h and 0<=nx<w:
            if m[ny][nx]>m[y][x]+1 and field[ny][nx]==".":
                m[ny][nx]=m[y][x]+1
                queue.append([ny,nx])
                field[ny][nx]="#"

ans=0

for i in range(h):
    ans=max(ans,max(m[i]))

print(ans)

### FIXED CODE ###

h,w=map(int,input().split())
INF=10**10
a=[[INF for i in range(w)] for j in range(h)]
ans=0
for i in range(h):
    s=input()
    for j in range(w):
        if s[j]=="#":
            a[i][j]=0
            
for i in range(h):
    for j in range(w):
        k=a[i][j]+1

        if i!=h-1:
            if k<a[i+1][j]:
                a[i+1][j]=k
        if j!=w-1:
            if k<a[i][j+1]:
                a[i][j+1]=k

for i in range(h):
    for j in range(w):
        k=a[-1-i][-1-j]+1
        if i!=h-1:
            if k<a[-i-2][-j-1]:
                a[-i-2][-j-1]=k

        if j!=w-1:        
            if k<a[-i-1][-j-2]:
                a[-i-1][-j-2]=k

for i in range(h):
    ans=max(ans,max(a[i]))
print(ans)
### BUGGY CODE ###

n = int(input())
L = sorted(list(map(int,input().split())),reverse= True)
cnt = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if L[k]+L[j]>L[i]:
                cnt += 1
print(cnt)



### FIXED CODE ###

import bisect
n = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(n-1):
    for j in range(i+1,n):
        index = bisect.bisect_left(L,L[i]+L[j])
        ans += index - (j+1)

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

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [10 ** 9] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))

    for j in range(2, k+1):
        if i >= j:
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))

print(dp[-1])

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [10 ** 9] * n
dp[0] = 0

for i in range(1, n):
    j = max(0, i - k)
    hi = h[i]
    dp[i] = min(dpj + abs(hi - hj) for dpj, hj in zip(dp[j:i], h[j:i]))

print(dp[-1])
### BUGGY CODE ###

num_of_candidate, start_point, num_of_questions = map(int, input().split())
winner_list = [int(input()) for i in range(num_of_questions)]

if start_point > num_of_questions:
	for i in range(num_of_candidate):
		print("Yes")
	exit()


point_list = [start_point for i in range(num_of_candidate)]

for i in range(num_of_questions):
	winner_id = winner_list[i]
	for j in range(num_of_candidate):
		if j != winner_id - 1:
			point_list[j] -= 1

for i in range(num_of_candidate):
	if point_list[i] > 0:
		print("Yes")
	else:
		print("No")

### FIXED CODE ###

import numpy as np

num_of_candidate, start_point, num_of_questions = map(int, input().split())
# winner_list = [int(input()) for i in range(num_of_questions)]
if start_point > num_of_questions:
	for i in range(num_of_candidate):
		print("Yes")
	exit()


start_points = np.array([start_point for i in range(num_of_candidate)])

got_points = np.array([0 for i in range(num_of_candidate)])
for i in range(num_of_questions):
	winner_id = int(input())
	got_points[winner_id - 1] += 1

lost_points = np.array([num_of_questions for i in range(num_of_candidate)]) - got_points

result_points = start_points - lost_points

for i in range(num_of_candidate):
	if result_points[i] > 0:
		print("Yes")
	else:
		print("No")
### BUGGY CODE ###

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


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
r = [0]*n
for i in range(n-1):
    r[a[i]-1] += 1
[print(r[i]) for i in range(n)]
### BUGGY CODE ###

import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    n, p = MII()
    s = list(map(int, IS()))
    if 10%p == 0: # pが2または5の場合
        cnt = 0
        for i, si in enumerate(s):
            if si%p == 0:
                cnt += i+1
        print(cnt)
        return None

    d = {i: 0 for i in range(p)}
    d[0] = 1
    ss = 0
    x = 1
    for si in s[::-1]:
        ss += x*si
        ss %= p
        d[ss] += 1
        x = 10*x
    cnt = 0
    for dv in d.values():
        cnt += dv*(dv-1)//2
    print(cnt)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    n, p = MII()
    s = list(map(int, IS()))
    if 10%p == 0: # pが2または5の場合
        cnt = 0
        for i, si in enumerate(s):
            if si%p == 0:
                cnt += i+1
        print(cnt)
        return None

    d = {i: 0 for i in range(p)}
    d[0] = 1
    ss = 0
    x = 1
    for si in s[::-1]:
        ss += x*si
        ss %= p
        d[ss] += 1
        x = 10*x%p
    cnt = 0
    for dv in d.values():
        cnt += dv*(dv-1)//2
    print(cnt)


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

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]

L = []

cnt_sum = 0
min_num = BC[0][1]
for i in range(M):
    cnt = BC[i][0]
    for j in range(N):
        if cnt_sum <= N:
            L.append(BC[i][1])
            cnt_sum += 1
            cnt -= 1
            if BC[i][1] < min_num:
                min_num = BC[i][1]
        else:
            if BC[i][1] < min_num:
                break
            if L[j] < BC[i][1]:
                L[j] = BC[i][1]
                cnt -= 1
        if cnt <= 0:
            break
# for i in range(M):
#     for j in range(BC[i][0]):
#         L.append(BC[i][1])
L.sort(reverse=True)
A.sort()
ans = sum(A)
LL = len(L)
for k in range(N):
    if k <= LL-1 and L[k] > A[k]:
        ans += (L[k] - A[k])
    else:
        break
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]

L = []
BC.sort(key=lambda x:x[1], reverse=True)
A.sort()
# ans = sum(A)
ans = 0
# flag = False
cnt = 0
# for k in range(N):
#     if k <= len_L-1:
#         if flag and L[k] > A[k]:
#             ans += L[k]
#         else:
#             flag = False
#             ans += A[k]
#     else:
#         ans += A[k]
for i in range(M):
    for j in range(BC[i][0]):
        if cnt < N and A[cnt] < BC[i][1]:
            ans += BC[i][1]
            cnt += 1
        else:
            break
    else:
        continue
    break

if cnt < N:
    ans += sum(A[cnt::])

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

import numpy as np
def get_input():
    N = int(input())
    a = [int(input()) for i in range(N)]
    return N,a

MOD =998244353
def solve(N,a):
    sum_a = sum(a)
    dp = np.zeros((N+1,sum_a+1))
    dp[0][0] = 1
    for j in range(1,N+1):
        dp[j][0] = (2 * dp[j-1][0])%MOD

    for i in range(1,N+1):
        for j in range(1,sum_a+1):
            if j-a[i-1]>=0:
                dp[i][j] = ( dp[i][j] + dp[i-1][j]*2 +dp[i-1][j-a[i-1]])%MOD
            else:
                dp[i][j] = ( dp[i][j] + dp[i-1][j]*2 )%MOD
    all_combination = 1
    for i in range(N):
        all_combination = (all_combination*3) %MOD
    half_sum_a = sum_a //2 if sum_a %2 == 0 else sum_a//2+1 
    bigger_than_half = np.sum(dp[N][half_sum_a:])
    if sum_a %2 == 0:
        half_dp = np.zeros((N+1,sum_a+1))
        half_dp[:,0] = 1
        for i in range(1,N+1):
            for j in range(1,sum_a+1):
                if j-a[i-1]>=0:
                    half_dp[i][j] = ( half_dp[i][j] + half_dp[i-1][j] +half_dp[i-1][j-a[i-1]])%MOD
                else:
                    half_dp[i][j] = ( half_dp[i][j] + half_dp[i-1][j] )%MOD
        half_half = half_dp[N][half_sum_a]
        
    else:
        half_half = 0
    return int(all_combination - 3* bigger_than_half + 3* half_half)%MOD

    
if __name__ =="__main__":
    N,a = get_input()
    ans = solve(N,a)
    print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
a = np.array([int(input()) for i in range(N)])
MOD =998244353
sum_a = np.sum(a)
dp =  np.zeros((N+1,sum_a+1))
half_dp = np.zeros((N+1,sum_a//2+1))
dp[0][0] = 1
half_dp[0][0] = 1

for i in range(1,N+1):
    dp[i,:] += dp[i-1,:]*2 %MOD
    dp[i,a[i-1]:] +=  dp[i-1, :-a[i-1]]%MOD
    half_dp[i,:] +=  half_dp[i-1,:] %MOD
    half_dp[i,a[i-1]:] += half_dp[i-1,:-a[i-1]]%MOD

all_combination = 3**N %MOD
half_sum_a = sum_a //2 if sum_a %2 == 0 else sum_a//2+1 
bigger_than_half = np.sum(dp[N][half_sum_a:])
half_half = half_dp[N][half_sum_a] if sum_a%2==0 else 0
ans = int(all_combination - 3* bigger_than_half + 3* half_half)%MOD
print(ans)
### BUGGY CODE ###

n = int(input())
base = input().split()
x = []
for i in base:
    x.append(int(i))
for i in range(1,n):
    a = x.count(i)
    print(a)
    for s in range(a):
        del x[0]
print(0)

### FIXED CODE ###

import collections

n = int(input())
base = input().split()
x = []
for i in base:
    x.append(int(i))
#x.sort(reverse = False)
c = collections.Counter(x)
for i in range(1,n):
    print(c[i])
print(0)
### BUGGY CODE ###

N=int(input())
L=[]
for i in range(N):
  L.append(int(input()))
ans=0
for i in set(L):
  if L.count(i)%2==1:
    ans=ans+1
print(ans)

### FIXED CODE ###

n = int(input())
s = set()
for i in range(n):
  a = input()
  if a in s:
    s.remove(a)
  else:
    s.add(a)
print(len(s))
### BUGGY CODE ###

N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]

A.sort()
B.sort()
C.sort()

A_pat = [0] * N
B_pat = [0] * N

c = 0
for b in range(N):
    for i in range(c,N):
        if B[b] < C[i]:
            c = i                 
            B_pat[b] = N-i   
            break
b = 0       
for a in range(N):
    for i in range(b,N):
        if A[a] < B[i]:
            b = i
            A_pat[a] = sum(B_pat[i:])         
            break
print(sum(A_pat))


### FIXED CODE ###

N = int(input())
A = [[int(a),"A"] for a in input().split()]
B = [[int(b),"B"] for b in input().split()]
C = [[int(c),"C"] for c in input().split()]

parts = A+B+C
parts.sort(key = lambda x:x[1])
parts.sort(reverse = True,key = lambda x:x[0])

A_pat = [0]  
B_pat = [0]
C_count = 0

for s,t in parts:
    if t=="C":      
        C_count += 1
    elif t=="B":
        B_pat.append(C_count+B_pat[-1])
    elif t=="A":
        A_pat.append(B_pat[-1]+A_pat[-1])
print(A_pat[-1])
### BUGGY CODE ###

from collections import defaultdict
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = defaultdict(set)

for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  fr[a].add(b)
  fr[b].add(a)

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl[a].add(b)
  bl[b].add(a)

def dfs(i):
    ret = set()
    unvisited = [i]

    while len(unvisited) > 0:
        v = unvisited.pop()
        ret.add(v)
        for w in fr[v]:
            if w in ret or w in unvisited:
                continue
            unvisited.append(w)
    return ret


for i in range(n):
  s = dfs(i)
  for j in bl[i]:
    if j in s:
      s.remove(j)
  print(len(s) - len(fr[i]) - 1, end=' ')
print()

### FIXED CODE ###

from collections import defaultdict
import time
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = []
start = time.time()
group = [0] * n

for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  fr[a].add(b)
  fr[b].add(a)

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl.append((a,b))


g_num = 0
for i in range(n):
    if group[i] != 0:
        continue
    g_num += 1
    unvisited = set({i})
    while len(unvisited) > 0:
        v = unvisited.pop()
        group[v] = g_num
        for w in fr[v]:
            if group[w] > 0 or w in unvisited:
                continue
            unvisited.add(w)

group_size = defaultdict(int)
for x in group:
    group_size[x] += 1

bl_in_group = [0] * n
for a,b in bl:
    if group[a] == group[b]:
        bl_in_group[a] += 1
        bl_in_group[b] += 1

for i in range(n):
    print(group_size[group[i]] - len(fr[i]) - bl_in_group[i] - 1, end=' ')

print()
### BUGGY CODE ###

K, S = map(int,input().split())
count = 0
start = max(S - 2*K, 0)
for X in range(start,K+1):
    for Y in range(X,K+1):
        for Z in range(Y,K+1):
            if X+Y+Z == S:
                if X == Y and X == Z:
                    count += 1
                elif X == Y and Y != Z:
                    count += 3
                elif Y == Z  and Z != X:
                    count += 3
                else:
                    count += 6

print(count)

### FIXED CODE ###

K, S = map(int,input().split())
count = 0
start = max(S - 2*K, 0)

for X in range(start,K+1):
    for Y in range(start,K+1):
        Z = S - X - Y
        if Z >= 0 and Z <= K:
            count += 1
print(count)