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

import sys
input = sys.stdin.readline
h,w = map(int,input().split())
la = [list(map(int,input().split())) for i in range(h)]
lb = [list(map(int,input().split())) for i in range(h)]
k = (h+w)*80+2

dp = [[[-1 for l in range(k)] for i in range(w)] for j in range(h)]

dp[0][0][abs(la[0][0]-lb[0][0])] = 1


for i in range(h):
    for j in range(w):
        for l in range(k):
            if dp[i][j][l] == 1:
                if j + 1 < w:
                    a = abs(la[i][j+1]-lb[i][j+1])
                
                    dp[i][j+1][l+a] = 1
                    dp[i][j+1][abs(l-a)] = 1
                if i + 1 < h:
                    a = abs(la[i+1][j]-lb[i+1][j])
                
                    dp[i+1][j][l+a] = 1
                    dp[i+1][j][abs(l-a)] = 1
print(dp[-1][-1].index(1))

### FIXED CODE ###

import sys
input = sys.stdin.readline
h,w = map(int,input().split())
la = [list(map(int,input().split())) for i in range(h)]
for i in range(h):
    l = list(map(int,input().split()))
    for j,num in enumerate(l):
        la[i][j] = abs(la[i][j]-num)
dp = [[0 for i in range(w)] for j in range(h)]
k = (h+w)*80+2
dp[0][0] = 1 << (k+la[0][0]) | 1 << (k-la[0][0])

for i in range(h):
    for j in range(w):
        if i:
            dp[i][j] |= (dp[i-1][j] << la[i][j]) | dp[i-1][j] >> la[i][j]
        if j:
            dp[i][j] |= (dp[i][j-1] << la[i][j]) | dp[i][j-1] >> la[i][j]
        
s = bin(dp[-1][-1])[2:]
l = len(s)-1
ans = float('inf')
for i in range(l,-1,-1):
  if s[i]=='1':
    m = abs(l-i-k)
    if m<ans:
      ans = m
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

c = [None] * 200000
p = 0
st = 0
ed = 0
i = 0
while True:
    c[i] = p
    i += 1
    p = a[p]
    if p in c:
        st = c.index(p)
        ed = i
        break
if k < ed:
    print(c[k] + 1)
else:
    k -= st
    k %= ed - st
    print(c[st + k] + 1)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

c = [None] * 200000
cc = set()
p = 0
st = 0
ed = 0
i = 0
while True:
    c[i] = p
    cc.add(p)
    i += 1
    p = a[p]
    if p in cc:
        st = c.index(p)
        ed = i
        break
if k < ed:
    print(c[k] + 1)
else:
    k -= st
    k %= ed - st
    print(c[st + k] + 1)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import itertools
import sys

ships = []
N, M = [int(x) for x in input().split()]
for i in range(M):
    ships.append([int(x) for x in input().split()])

from_1 = [ship[1] for ship in ships if ship[0] == 1]
to_N = [ship[0] for ship in ships if ship[1] == N]

for land in from_1:
    if land in to_N:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")

### FIXED CODE ###

# -*- coding: utf-8 -*-

ships = []
N, M = [int(x) for x in input().split()]
for i in range(M):
    ships.append([int(x) for x in input().split()])

from_1 = set([ship[1] for ship in ships if ship[0] == 1])
to_N = set([ship[0] for ship in ships if ship[1] == N])

if from_1.intersection(to_N):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

import copy
N = int(input())
S = input()

hoge = ["R", "G", "B"]
ct = 0

def dfs(index, RGB, indexs):
    global ct
    if S[index] in RGB:
        return
    else:
        RGB += [S[index]]
        indexs += [index]
        
        if len(RGB) == 2:

            for i in hoge:
                if not i in RGB:
                    ct += list(S[index+1:]).count(i)
                    h = indexs[1]+indexs[1]+2 - (indexs[0]+1)

                    if 0 < h <= N and S[h-1] == i:
                        ct -= 1
                    
                    return

        for i in range(index+1, N):
            dfs(i, copy.copy(RGB), copy.copy(indexs))

for i in range(N):
    dfs(i, [], [])

print(ct)


### FIXED CODE ###

#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

import copy
N = int(input())
S = input()

# ct = 0

# def dfs(index, RGB, indexs):
#     global ct
#     if RGB[S[index]] == 1:
#         return
#     else:
#         RGB[S[index]] = 1
#         indexs += [index]
        
#         if len(indexs) == 2:

#             for key, value in RGB.items():
#                 if value == 0:
#                     ct += Counter(S[index+1:])[key]
#                     h = indexs[1]+indexs[1] - indexs[0] +1
#                     if 0 < h <= N and S[h-1] == key:
#                         ct -= 1

#                     return

#         for i in range(index+1, N):
#             dfs(i, RGB.copy(), copy.copy(indexs))

# for i in range(N):
#     dfs(i, {"R":0, "G":0, "B":0}, [])

# print(ct)

c = Counter(S)
al = c["R"] * c["G"] * c["B"]

for i in range(N):
    for j in range(i+1, N):
        k = 2*j - i
        if k >= N: break
        if S[i] != S[k] and S[i] != S[j] and S[j] != S[k]:
            al -= 1
print(al)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
for i in range(Q):
  l,r = map(int,input().split())
  tmp = S[l-1:r]
  print(tmp.count('AC'))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
### BUGGY CODE ###

import numpy as np
N,M = list(map(int, input().split()))
S = np.array(list(map(int, input().split())))
T = np.array(list(map(int, input().split())))
mod = int(1e9+7)
"""
dp[i][j] : S の i 文字目までと T の j 文字目までを考慮し、
この 2 文字 (S[i] と T[j]）をペアにするときの場合の数とすると、

dp[i][j] = (sum(dp[1:i-1][1:j-1]) + 1 if S[i] == T[j] else 0)
このsumの部分をどうもとめるか。

最終的な答えはsum(dp[:][:])。

2-D cumsumをつかう
i,j = 0のときにきをつけて
DS[i][j] = DS[i-1][j] + DS[i][j-1] - DS[i-1][j-1] + dp[i][j]
"""

#dp = [[ 0 for _ in range(M)] for _ in range(N)]
dp = np.zeros((N,M))
# -1のIndexAccessをゼロにしたいので、ひとつ大きめに取っておく。
DS = np.zeros((N+1,M+1))

for i in range(N):
  for j in range(M):
    if S[i] != T[j]:
      dp[i, j] = 0
    else:
      dp[i, j] += 1
    ## 愚直ループを2次元部分和でなんとかする
    #for k in range(i):
    #  for l in range(j):
    #    dp[i][j] += dp[k][l]
    ## 愚直ループnp版。
      #dp[i,j] += np.sum(dp[:i, :j])
      dp[i,j] += DS[i-1,j-1]
      dp[i,j] %= mod
    DS[i,j] = DS[i-1,j] + DS[i,j-1] - DS[i-1,j-1] + dp[i,j]
    DS[i,j] %= mod
print(int(DS[-2][-2])+1)
#print(dp)
#print(DS)


### FIXED CODE ###

# numpyでかいてもTLEした。
# pypyでlistでかくととおる？

#import numpy as np
N,M = list(map(int, input().split()))
S = list(map(int, input().split()))
T = list(map(int, input().split()))
mod = int(1e9+7)
"""
dp[i][j] : S の i 文字目までと T の j 文字目までを考慮し、
この 2 文字 (S[i] と T[j]）をペアにするときの場合の数とすると、

dp[i][j] = (sum(dp[1:i-1][1:j-1]) + 1 if S[i] == T[j] else 0)
このsumの部分をどうもとめるか。

最終的な答えはsum(dp[:][:])。

2-D cumsumをつかう
i,j = 0のときにきをつけて
DS[i][j] = DS[i-1][j] + DS[i][j-1] - DS[i-1][j-1] + dp[i][j]
"""

dp = [[ 0 for _ in range(M)] for _ in range(N)]
DS = [[ 0 for _ in range(M+1)] for _ in range(N+1)]

for i in range(N):
  for j in range(M):
    if S[i] != T[j]:
      dp[i][j] = 0
    else:
      dp[i][j] += 1
      dp[i][j] += DS[i-1][j-1]
      dp[i][j] %= mod
    DS[i][j] = DS[i-1][j] + DS[i][j-1] - DS[i-1][j-1] + dp[i][j]
    DS[i][j] %= mod
print(DS[-2][-2]+1)
#print(dp)
#print(DS)
### BUGGY CODE ###

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
second = []
flag = False
for x in range(M):
    if ab[x][0] == 1:
        second.append(ab[x][1])

for y in range(len(second)):
    for z in range(M):
        if ab[z][0] == second[y] and ab[z][1] == N:
            flag = True
if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
start = []
goal = []
flag = False
for x in range(M):
    if ab[x][0] == 1:
        start.append(ab[x][1])

    if ab[x][1] == N:
        goal.append(ab[x][0])

start_goal = set(start) & set(goal)

if start_goal:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

import sys

N,*S = map(int, open(0).read().split())
S = sorted(S)

g = [S.pop(-1)]

for gen in range(N):
    g.sort(reverse=True)
    for p in g[:2**gen]:
        for si, s in enumerate(S[::-1]):
            if p > s:
                g.append(s)
                S.pop(-(si+1))
                break
        else:
            print('No')
            sys.exit()
print('Yes')

### FIXED CODE ###

## 他の方と処理内容がほぼ同じなのに何でTLEになるか分からないので、他の方のコードでテスト
N = int(input())
a = list(map(int,input().split(' ')))
a.sort()
    

fathers = [a.pop()]
for _ in range(N):
    sons = list()
    b = list()
    
    for father in fathers:
        while a:
            x = a.pop()
            if father > x:
                sons.append(x)
                break
            else:
                b.append(x)
                
    a = a + b[::-1]
    fathers.extend(sons)
    fathers.sort(reverse = True)
    
    
    
if len(fathers) == 2**N:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

job = list()
salary = list()
m_total = 0
j = 0
n,m = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))
    job.sort(reverse = True)
for i in range(n):
    a,b = job[i]
    salary.append(b)
    if a + j > m :
        salary.remove(min(salary))
        continue
    j += 1
print(sum(salary))


### FIXED CODE ###

import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

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

def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
s=input()
n=len(s)
a=[]
for i in range(n):
  if s[i]=='P':
    a.append('P')
  else:
    a.append('D')
print(convert(a))

### FIXED CODE ###

s=input()
print(s.replace('?','D'))
### BUGGY CODE ###

n = input()
xn = list(map(int, input().split()))
for i in range(len(xn)):
    tmp = xn.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[int((int(n) - 1) / 2)])

### FIXED CODE ###

n = int(input())
xn = list(map(int, input().split()))
xn_s = sorted(xn)
m1 = xn_s[n//2 - 1]
m2 = xn_s[n//2]
for x in xn:
    if x <= m1:
        print(m2)
    else:
        print(m1)
### BUGGY CODE ###

N=int(input())
D,M,C,A=map(ord,'DMCA')
S=[ord(c)-A for c in input()]
Q=int(input())
K=list(map(int,input().split()))
DMC=[D-A,M-A,C-A]
for k in K:
    dmc=[0,0,0]
    dm=0
    a=0
    for i,s in enumerate(S):
        if i>=k:
            if S[i-k] in DMC:
                m=DMC.index(S[i-k])
                dmc[m]-=1
                if m==0:
                    dm-=dmc[1]
        if s in DMC:
            p=DMC.index(s)
            dmc[p]+=1
            if p==1:
                dm+=dmc[0]
            if p==2:
                a+=dm
    print(a)

### FIXED CODE ###

N=int(input())
D,M,C=map(ord,'DMC')
import numpy as np
S=np.array([ord(c) for c in input()])
input()
K=map(int,input().split())
iD=S==D
iM=S==M
iC=S==C
cD=np.cumsum(iD,dtype=np.int64)
cM=np.cumsum(iM,dtype=np.int64)
for k in K:
    cD2=cD-np.concatenate((np.zeros(k,dtype=np.int64),cD[:-k]))
    cM2=cM-np.concatenate((np.zeros(k,dtype=np.int64),cM[:-k]))
    DM=np.cumsum(cD2*iM-np.concatenate((np.zeros(k,dtype=np.int64),cM2[k-1:-1]*iD[:-k])))
    print(np.sum(iC*DM))
### BUGGY CODE ###

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()

for i in range(1,n+1):
    print(a.count(i))

### FIXED CODE ###

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()
ans=[0]*n

for i in range(len(a)):
    ans[a[i]-1]+=1
for i in range(len(ans)):
    print(ans[i])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
# sys.setrecursionlimit(10000000)
# INF = 1<<32s


def solve(N: int, S: str):
    ans = 0
    for i in range(1000):
        si = format(i, '03')

        idx = 0
        for j in range(len(S)):
            if idx >= len(si):
                break
            elif si[idx] == S[j]:
                idx += 1

        if idx == len(si):
            ans += 1

    print(ans)
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = str(next(tokens))  # type: int
    solve(N, S)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# sys.setrecursionlimit(10000000)
# INF = 1<<32s


def solve(N: int, S: str):
    ans = 0
    for i in range(1000):
        si = format(i, '03')

        idx = 0
        for j in range(len(S)):
            if idx >= len(si):
                break
            elif si[idx] == S[j]:
                idx += 1

        if idx == len(si):
            ans += 1

    print(ans)
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = str(next(tokens))  # type: int
    solve(N, S)

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

from collections import Counter
import math
import sys
def solve():
    N = int(input())
    A = list(map(int,sys.stdin.readline().split()))

    st = set(A)
    counter = Counter(A)

    ans = 0
    for i in range(N):
        if counter[A[i]] >= 2:
            continue
        divisors = calc_divisors(A[i])
        for divisor in divisors:
            if divisor == A[i]:
                continue
            if divisor in st:
                break
        else:
            ans += 1
    
    print(ans)

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

    return divisors

if __name__ == '__main__':
    solve()


### FIXED CODE ###

from collections import Counter
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    dp = [True] * (10 ** 6 + 1)
    counter = Counter(A)

    A.sort()
    ans = 0
    for a in A:
        if dp[a]:
            if counter[a] == 1:
                ans += 1
            i = a
            while i <= 10 ** 6:
                dp[i] = False
                i += a
    
    print(ans)

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

h, n = map(int, input().split())
dp = [10**10]*(h+10**4+1)
dp[0] = 0

for _ in range(n):
  a, b = map(int, input().split())
  for i in range(a, len(dp)):
    dp[i] = min(dp[i-a]+b, dp[i])

print(min(dp[h:]))

### FIXED CODE ###

h, n = map(int, input().split())
dp = [10**10]*(h+10**4+1)
dp[0] = 0

for _ in range(n):
  a, b = map(int, input().split())
  for i in range(a, len(dp)):
    dp[i] = min(dp[i-a]+b, dp[i])

print(min(dp[h:]))
### BUGGY CODE ###

H,W,N = map(int,input().split())
if N == 0:
  print((H-2)*(W-2))
  for i in range(9):
    print(0)
  exit()

AB = [list(map(int,input().split())) for _ in range(N)]

Board = [[0 for _ in range(W)] for _ in range(H)]
Done = [[0 for _ in range(W)] for _ in range(H)]
Count = [0 for _ in range(10)]

for a,b in AB:
  Board[a-1][b-1] = 1
for a,b in AB:
  a -= 1
  b -= 1
  for i in range(-1,2):
    for j in range(-1,2):
      if 1 <= a+i <= H-2 and 1 <= b+j <= W-2:
        if Done[a+i][b+j] == 1:
          continue
        c = 0
        for k in range(-1,2):
          for l in range(-1,2):
            c += Board[a+i+k][b+j+l]
        Count[c] += 1
        Done[a+i][b+j] = 1
Count[0] = (H-2)*(W-2)-sum(Count[1:])
for c in Count:
  print(c)

### FIXED CODE ###

from collections import defaultdict

H,W,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

Cells = defaultdict(int)
Count = [(H-2)*(W-2)] + [0 for _ in range(9)]

for a,b in AB:
  a -= 1
  b -= 1
  for i in range(-1,2):
    for j in range(-1,2):
      if 1 <= a+i <= H-2 and 1 <= b+j <= W-2:
        Count[Cells[(a+i,b+j)]] -= 1
        Count[Cells[(a+i,b+j)]+1] += 1
      Cells[(a+i,b+j)] += 1
for c in Count:
  print(c)
### BUGGY CODE ###

import collections

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A_dict=collections.Counter(A)
B_dict=collections.Counter(B)
C_dict=collections.Counter(C)

A_sorted=sorted(A_dict)
B_sorted=sorted(B_dict)
C_sorted=sorted(C_dict)

B_sum=len(B)
C_sum=len(C)

ans=0

for i in A_sorted:
    for j in B_sorted:
        C_num = C_sum
        if i < j:
            for k in C_sorted:
                if k <= j:
                    C_num -= C_dict[k]
                else:
                    break

            ans += A_dict[i] * B_dict[j] * C_num

print(ans)

### FIXED CODE ###

from bisect import bisect_left
from bisect import bisect_right

N=int(input())

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

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

ans=0
for i in range(N):
    idxa=bisect_left(A,B[i])
    idxc=bisect_right(C,B[i])
    ans+=idxa*(N-idxc)

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

n = int(input())
A = sorted(map(int, input().split()), reverse=True)
ans = 0
mod = 10 ** 9 + 7
for i in range(61):
    cnt0 = cnt1 = 0
    for j, a in enumerate(A):
        if a < 2 ** i:
            cnt0 += n - j
            break
        if (a >> i) & 1:
            cnt1 += 1
        else:
            cnt0 += 1
    ans += (((2 ** i) % mod) * ((cnt1 * cnt0) % mod)) % mod
    ans %= mod

print(ans)


### FIXED CODE ###

def main():
    n = int(input())
    A = sorted(map(int, input().split()), reverse=True)
    ans = 0
    mod = 10 ** 9 + 7
    m=A[0]
    for i in range(61):
        cnt0 = cnt1 = 0
        if m < 2 ** i:
            break
        for j, a in enumerate(A):
            if a < 2 ** i:
                cnt0 += n - j
                break
            if (a >> i) & 1:
                cnt1 += 1
            else:
                cnt0 += 1
        ans += (((2 ** i) % mod) * ((cnt1 * cnt0) % mod)) % mod
        ans %= mod

    print(ans)

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

N,K=map(int,input().split())
dp=[1000000000000000]*N
h=[int(x) for x in input().split()]
dp[0]=0
for i in range(N):
    dp=dp[:i] + ([x if x<dp[i]+abs(h[i+j]-h[i]) else dp[i]+abs(h[i+j]-h[i]) for j,x in enumerate(dp[i:(i+K+1 if i+K+1<N else N)])]) + (dp[i+K+1:] if i+K+1<N else [])
#    for j in range(i,i+K+1 if i+K+1 < N else N):
#        dp[j] = dp[j] if dp[j]<dp[i]+abs(h[j]-h[i]) else dp[i]+abs(h[j]-h[i])
print(dp[-1])

### FIXED CODE ###

N,K=map(int,input().split())
dp=[1000000000000000 for i in range(N)]
h=[int(x) for x in input().split()]
dp[0]=0
for i in range(N):
    for j in range(i,i+K+1 if i+K+1 < N else N):
        dp[j] = dp[j] if dp[j]<dp[i]+abs(h[j]-h[i]) else dp[i]+abs(h[j]-h[i])
print(dp[-1])
### BUGGY CODE ###

s = input()
j = [str(x) for x in list(str(s))]
t = input()
k = [str(x) for x in list(str(t))]

for i in range(len(j)):
    if j[i] != k[i]:
        com = j[i]
        j[i] = k[i]
        for h in range(len(j)):
            if j[h] == com:
                j[h] = k[i]
            elif j[h] == k[i] and h != i:
                j[h] = com

if j == k:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input()
j = [str(x) for x in list(str(s))]
t = input()
k = [str(x) for x in list(str(t))]

ar = []

for i in range(len(j)):
    if j[i] != k[i]:
        if j[i] in ar:
            break
        """if j[i] not in ar:
            ar.append(j[i])"""
        com = j[i]
        j[i] = k[i]
        if j[i] not in ar:
            ar.append(j[i])
        for h in range(len(j)):
            if j[h] == com:
                j[h] = k[i]
            elif j[h] == k[i] and h != i:
                j[h] = com
        for g in range(i + 1):
            if j[g] != k[g]:
                break
        else:  # 内側のforのelse節は内側ループが全部まわり切ったら実行される、つまり前の行のbreakで抜けた場合ここは実行されない
            continue  # 外側のforに対応するcontinue文、ここが実行されたら次の行のbreakには処理がいかず、外側のforの次のループにジャンプする
        break  # 外側のforを抜ける

if j == k:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

#!/usr/bin/env python3

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

def main():
    A_max = max(A)
    kaijo_table = [1 for _ in range(A_max + 1)]
    tmp = 1
    for i in range(1, A_max + 1):
        tmp *= i
        kaijo_table[i] = tmp
    my_max = 0
    for a in A:
        if a != A_max:
            tmp = (kaijo_table[A_max] // 
            (kaijo_table[a] * kaijo_table[A_max - a]))
            if my_max <= tmp:
                my_max = tmp
                ans = (A_max, a)
    print(" ".join(map(str, ans)))

if __name__ == "__main__":
    main()

### FIXED CODE ###

#!/usr/bin/env python3

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A_sorted = sorted(A)
    A_max = A_sorted[-1]
    A = A_sorted[:-1]
    tansaku = (A_max + 1) // 2
    ok = 0
    ng = len(A) - 1
    if A[ok] > tansaku:
        print(A_max, A[ok])
        exit()
    if A[ng] <= tansaku:
        print(A_max, A[ng])
        exit()
    while ok + 1 < ng:
        center = (ok + ng) // 2
        if A[center] <= tansaku:
            ok = center
        else:
            ng = center
    if tansaku - A[ok] <= A[ng] - tansaku:
        print(A_max, A[ok])
    else:
        print(A_max, A[ng])

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

def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [[(j, i), (-1, -1)] for i, j in enumerate(a)]
    ans = 0
    for i in range(1, 2**n):
        (t1, t2), (t3, t4) = d[i]
        for j in range(len(bin(i))-2):
            (t5, t6), (t7, t8) = d[i & ~(1 << j)]
            if t6 not in [t2, t4]:
                if t5 > t1:
                    t1, t2, t3, t4 = t5, t6, t1, t2
                elif t5 > t3:
                    t3, t4 = t5, t6
            if t8 != t4:
                if t7 > t3:
                    t3, t4 = t7, t8
        d[i] = [(t1, t2), (t3, t4)]
        ans = max(ans, t1+t3)
        print(ans)


main()

### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [[(j, i), (-1, -1)] for i, j in enumerate(a)]
    ans = 0
    for i in range(1, 2**n):
        (t1, t2), (t3, t4) = d[i]
        for j in range(n):
            (t5, t6), (t7, t8) = d[i & ~(1 << j)]
            if t6 not in [t2, t4]:
                if t5 > t1:
                    t1, t2, t3, t4 = t5, t6, t1, t2
                elif t5 > t3:
                    t3, t4 = t5, t6
            if t8 not in [t2, t4]:
                if t7 > t3:
                    t3, t4 = t7, t8
        d[i] = [(t1, t2), (t3, t4)]
        ans = max(ans, t1+t3)
        print(ans)


main()
### BUGGY CODE ###

import itertools as it
n = int(input())
s = [int(input()) for _ in range(n)]

ans = [0]
for i in range(1,n+1) :
    sa = list(it.combinations(s,i))
    for j in range(len(sa)) :
        if sum(sa[j])%10 != 0 :
            ans.append(sum(sa[j]))

print(max(ans))

### FIXED CODE ###

n = int(input())
sum = 0
s = []
for i in range(n) :
    x = int(input())
    sum += x
    if x%10 != 0 :
        s.append(x)


if sum %10 != 0 :
    print(sum)
    exit()

while len(s)>0 :
    m = min(s)
    sum -= m
    if sum%10 != 0 :
        print(sum)
        exit()

print(0)