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

from collections import deque


diff = ((0, 1), (0, -1), (1, 0), (-1, 0))
n = int(input())
p = list(map(int, input().split()))

cost = [[0] * n for i in range(n)]
for i in range(n):
    for j in range(n):
        cost[i][j] = min(i, j, n - i - 1, n - j - 1) + 1

occ = [[True] * n for i in range(n)]
ans = 0
for start in p:
    i, j = divmod(start - 1, n)
    q = deque([(i, j)])
    ans += cost[i][j] - 1
    occ[i][j] = False

    while q:
        i, j = q.popleft()
        for di, dj in diff:
            nxt_i = i + di
            nxt_j = j + dj
            if not(0 <= nxt_i < n and 0 <= nxt_j < n):
                continue
            elif not occ[i][j] and not occ[i][j] and cost[nxt_i][nxt_j] > cost[i][j]:
                cost[nxt_i][nxt_j] = cost[i][j]
                q.append((nxt_i, nxt_j))
            elif cost[nxt_i][nxt_j] > cost[i][j] + 1:
                cost[nxt_i][nxt_j] = cost[i][j] + 1
                q.append((nxt_i, nxt_j))

print(ans)

### FIXED CODE ###

from collections import deque
import sys
imput = sys.stdin.readline


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

cost = [0] * (n * n)
for i in range(n):
    for j in range(n):
        cost[i * n + j] = min(i, j, n - i - 1, n - j - 1)

occ = [True] * (n * n)
ans = 0
for start in p:
    start -= 1
    q = deque([start])
    ans += cost[start]
    occ[start] = False
    while q:
        ij = q.popleft()
        i, j = divmod(ij, n)

        nxt_ij = (i + 1) * n + j
        if not(0 <= i + 1 < n and 0 <= j < n):
             pass
        elif not occ[ij] and cost[nxt_ij] > cost[ij]:
            cost[nxt_ij] = cost[ij]
            q.append(nxt_ij)
        elif cost[nxt_ij] > cost[ij] + 1:
            cost[nxt_ij] = cost[ij] + 1
            q.append(nxt_ij)
              
        nxt_ij = (i - 1) * n + j
        if not(0 <= i - 1 < n and 0 <= j < n):
            pass
        elif not occ[ij] and cost[nxt_ij] > cost[ij]:
            cost[nxt_ij] = cost[ij]
            q.append(nxt_ij)
        elif cost[nxt_ij] > cost[ij] + 1:
            cost[nxt_ij] = cost[ij] + 1
            q.append(nxt_ij)

        nxt_ij = i * n + (j + 1)
        if not(0 <= i + 0 < n and 0 <= j + 1 < n):
            pass
        elif not occ[ij] and cost[nxt_ij] > cost[ij]:
            cost[nxt_ij] = cost[ij]
            q.append(nxt_ij)
        elif cost[nxt_ij] > cost[ij] + 1:
            cost[nxt_ij] = cost[ij] + 1
            q.append(nxt_ij)

        nxt_ij = i * n + (j - 1)
        if not(0 <= i < n and 0 <= j - 1 < n):
            pass
        elif not occ[ij] and cost[nxt_ij] > cost[ij]:
            cost[nxt_ij] = cost[ij]
            q.append(nxt_ij)
        elif cost[nxt_ij] > cost[ij] + 1:
            cost[nxt_ij] = cost[ij] + 1
            q.append(nxt_ij)
print(ans)
### BUGGY CODE ###

n = int(input())
cnt = 0
A = []
for _ in range(n):
    A.append(input()) 
for i in range(n-1):
    s = sorted(A[i])
    for j in range(i+1, n):
        t = sorted(A[j])
        if s == t:
            cnt += 1
print(cnt)
         


### FIXED CODE ###

n = int(input())
cnt = 0
A = []
for _ in range(n):
    t = sorted(input())
    t = "".join(t)
    A.append(t)

import collections
C = collections.Counter(A)
lC = list(C.values())
for i in lC:
    cnt += i * (i-1) // 2
print(cnt)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
s=sum(a)
sunuke=0
arai=0
ans=10**18
for i in range(1,n):
    sunuke=sum(a[:i])
    arai=s-sunuke
    t=abs(sunuke-arai)
    ans=min(t,ans)
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
X = [0]*N

S = sum(A)
ans = 10**11

for i in range(N-1):
    X[i+1] = X[i] + A[i]

print(min(abs(S-2*X[i]) for i in range(1,N)))
### BUGGY CODE ###

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

List.sort()

counter = 0

for i in range(0, n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if List[i] + List[j] > List[k]:
        counter += 1
print(counter)

### FIXED CODE ###

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

ans = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    a = lst[i]
    b = lst[j]
    border = a + b
    dig = bisect.bisect_left(lst, border)
    ans += max(0, dig - j - 1)
    
print(ans)
### BUGGY CODE ###

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

M = []
for i in range(H):
  M.append([c == '.' for c in list(input().strip())])

max_size = 0
max_pos = None
for i in range(H):
  for j in range(W):
    if not M[i][j]:
      continue

    a = 1
    for x in range(j + 1, W):
      if not M[i][x]: break
      a += 1
    for x in range(j - 1, -1, -1):
      if not M[i][x]: break
      a += 1
    for y in range(i + 1, H):
      if not M[y][j]: break
      a += 1
    for y in range(i - 1, -1, -1):
      if not M[y][j]: break
      a += 1

    if a > max_size:
      max_size = a
      max_pos = (i, j)

print(max_size)
#print(max_size, max_pos)

### FIXED CODE ###

class Counter:
  def __init__(self):
    self.v = 0

  def increment(self):
    self.v += 1


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

M = [None] * H
MX = [None] * H
MY = [None] * H

for i in range(H):
  M[i] = [c == '.' for c in input().strip()]
  MX[i] = [None] * W
  MY[i] = [None] * W

max_size = 0

for i in range(H):
  for j in range(W):
    if not M[i][j]: continue

    if MX[i][j] is None:
      tmp = Counter()
      for x in range(j, W):
        if not M[i][x]: break
        MX[i][x] = tmp
        tmp.increment()

    if MY[i][j] is None:
      tmp = Counter()
      for y in range(i, H):
        if not M[y][j]: break
        MY[y][j] = tmp
        tmp.increment()

    size = MX[i][j].v + MY[i][j].v - 1
    max_size = max(max_size, size)

print(max_size)
### BUGGY CODE ###

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

dp = [[None for _ in range(N+1)] for _ in range(W+1)]

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

def f(dp,wleft,index):
  if index > N:
    return 0
  if dp[wleft][index] is not None:
    return dp[wleft][index]
  
  if wleft < items[index-1][0]:
    return f(dp,wleft,index+1)
  
  return max(f(dp,wleft,index+1),items[index-1][1]+f(dp,wleft-items[index-1][0],index+1))
  
print(f(dp,W,1))


### FIXED CODE ###

import numpy as np
N,W = map(int, input().split())
# np.maximum https://www.sejuku.net/blog/69175
# 第一引数と第二引数の大小関係を要素ごとに比較して、大きい方を格納した配列を返す
dp = np.zeros(W+1, dtype=np.int64)
# その重さでの最大valueが保存されている
for _ in range(N):
    w,v = map(int,input().split())
    # w以下ならvを足したもの、w以上ならそのままの値で、最大値を求める
    # 出力はw以上の配列として返す(それ以下は重さwなので関与しない)
    # 足す場合が前者、足さない場合が後者
    np.maximum(dp[:W-w+1]+v,dp[w:],out=dp[w:]) 

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

from heapq import heappop, heappush

N,Q=map(int,input().split())
E=[]
for a in range(N):
    s,t,x=map(int,input().split())
    E.append((s-x,1,x))
    E.append((t-x,0,x))

for a in range(Q):
    E.append((int(input()),2,0))
E.sort()
 
S=set()
H=[]
for time_,type_,x in E:
    if type_==1:
        S.add(x)
        heappush(H,x)
    elif type_==0:
        S.remove(x)
    else:
        while H and H[0] not in S:
            heappop(H)
        print(H[0] if H else -1)

### FIXED CODE ###

import sys
from heapq import heappop, heappush

input = sys.stdin.readline
N, Q = map(int, input().split())
event_list = []
for i in range(N):
  s, t, x = map(int, input().split())
  event_list.append([s-x, 1, x])
  event_list.append([t-x, -1, x])

for i in range(Q):
  event_list.append([int(input()), 2, 0])

ans = []
event_list.sort()
x_set = set()
x_list = []
for time, event, x in event_list:
  if event == 1:
    x_set.add(x)
    heappush(x_list, x)
  elif event == -1:
    x_set.remove(x)
  else:
    while x_list and x_list[0] not in x_set:
      heappop(x_list)
    if x_list:
      ans.append(x_list[0])
    else:
      ans.append(-1)

print(*ans, sep='\n')
### BUGGY CODE ###

N, M = map(int, input().split())
MOD = 1000000007

broken = []
for i in range(M):
    broken.append(int(input()))

dp = [0] * (N + 2)
dp[N] = 1
for i in reversed(range(N)):
    if i in broken:
        dp[i] = 0
        if len(broken) != 0:
            broken.pop(-1)
        continue
    dp[i] = (dp[i+1] + dp[i+2]) % MOD

print(dp[0])


### FIXED CODE ###

N, B = map(int, input().split())
ana = []
dp = [0] * (N+2)

for i in range(B):
    ana.append(int(input()))

mod = 1000000007

dp[N] = 1
for i in reversed(range(N)):
    if len(ana) >= 1 and i == ana[-1]:
        dp[i] = 0
        if len(ana) != 0:
            ana.pop(-1)
        continue
    dp[i] = dp[i + 1] + dp[i + 2]
print(dp[0] % mod)
### BUGGY CODE ###

N = int(raw_input())
foodlist = []
for i in range(N):
    foodlist.append(map(int, raw_input().split()))
#print foodlist
evalution_list = [0] * N
for i in range(N):
        evalution_list[i] = foodlist[i][0] + foodlist[i][1]
#print evalution_list

which_turn=0
points=[0,0]
for i in range(N):
    #print("turn is {0}".format(which_turn))
    choise = evalution_list.index(max(evalution_list))
    #print choise
    foodpoint=foodlist[choise][which_turn]
    #print foodpoint
    evalution_list[choise]=None
    points[which_turn] += foodpoint
    #print("point is {0}".format(points[which_turn]))
    
    which_turn += 1
    if which_turn > 1:
        which_turn=0
#print points
#print("point diff is {0}".format(points[0]-points[1]))
print("{0}".format(points[0]-points[1]))


### FIXED CODE ###

N = int(input())

AB =[]
X = 0
for i in range(N):
    A, B = map(int, input().split())

    AB.append(A+B)
    X += B * -1

AB.sort(reverse=True)


for i in range(0, N, 2):
    X += AB[i]


print(X)
### BUGGY CODE ###

import numpy as np
n=int(input())
s=[chr(i) for i in range(97, 97+26)]
 
aa_cij=np.array([[s.index(i)+1  for i in list(input())] for _ in range(n)],dtype='int8')

ans=0
for i in range(n):
  aa_cij=np.concatenate( [ aa_cij[1:,:], aa_cij[[0],:] ], axis=0)
  for j in range(n):
    aa_cij=np.concatenate( [ aa_cij[:,1:], aa_cij[:,[0]] ], axis=1)
    if np.allclose(aa_cij, aa_cij.T ):
      ans+=1 
print(ans)

### FIXED CODE ###

import numpy as np
n=int(input())
s=[chr(i) for i in range(97, 97+26)]
 
aa_cij=np.array([[s.index(i)+1  for i in list(input())] for _ in range(n)],dtype='int8')
z=np.zeros((n,n),dtype='int8')
ans=0
for i in range(n):
  aa_cij=np.concatenate( [ aa_cij[1:,:], aa_cij[[0],:] ], axis=0)
  if np.allclose(aa_cij - aa_cij.T, z ):
    ans+=1 
print(ans*n)
### BUGGY CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = sorted(readInts())
dic = defaultdict(int)
cnt = 0
# ------------
is_prime = [True] * (10**6+1)
#print('a')
for i in range(n):
    #ll += 1
    #print(i)
    if is_prime[A[i]] == True:
        for j in range(2*A[i], 10**6+1,A[i]):
            is_prime[j] = False # その素数の倍数のやつ

 # -----------
for i in A:
    dic[i] += 1
cnt = 0
for a in A:
    if is_prime[a] and not dic[a] >= 2:
        #print(a)
        cnt += 1
print(cnt)


### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = sorted(readInts())
dic = defaultdict(int)
cnt = 0
for i in A:
   dic[i] += 1
A = list(set(A))
# ------------
is_prime = [True] * (10**6+1)
#print('a')
for i in range(len(A)):
    #ll += 1
    #print(i)
    #print(A[i])
    if is_prime[A[i]] == True:
        for j in range(2*A[i], 10**6+1,A[i]):
            is_prime[j] = False # その素数の倍数のやつ

 # -----------
cnt = 0
if A[0] == 1:
    if dic[1] >= 2:
        print(0)
        exit()
    else:
        print(1)
        exit()
for a in A:
    if is_prime[a] and not dic[a] >= 2:
        #print(a)
        cnt += 1
print(cnt)
### BUGGY CODE ###

N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
  
cnt = A[0] - 1
cant_use = 1
for a in A[1:]:
  wk = a
  if wk == cant_use+1:
    #cnt += 1
    cant_use += 1
    continue
    
  while wk > cant_use:
    if wk % (cant_use+1) == 0:
      wk -= cant_use + 2
    else:
      wk -= cant_use + 1
    cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
  
cnt = A[0] - 1
cant_use = 1
for a in A[1:]:
  wk = a
  if wk == cant_use+1:
    #cnt += 1
    cant_use += 1
    continue
    
  if wk % (cant_use+1) == 0:
    wk -= cant_use + 2
    cnt += 1
  cnt += wk // (cant_use+1)
print(cnt)
### BUGGY CODE ###

h, w, n = map(int, input().split())
black = []
for _ in range(n):
    black.append([int(i) for i in input().split()])
count = [0 for _ in range(10)]
for k in range(w - 2):
    for l in range(h - 2):
        thisbox = 0
        for a in range(k,k+3):
            for b in range(l,l+3):
                if [b+1, a+1] in black:
                    thisbox += 1
        count[thisbox] += 1
for i in range(10):
    print(count[i])


### FIXED CODE ###

from collections import Counter, defaultdict

h, w, n = map(int, input().split())
hs, ws = h - 2, w - 2
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, hs)):
        for x in range(max(0, b - 3), min(b, ws)):
            dd[(y, x)] += 1

print(hs * ws - len(dd))

c = Counter(dd.values())
for i in range(1, 10):
    print(c[i] if i in c else 0)
### BUGGY CODE ###

n = int(input())
slist = []
scount = [1]
sinputlist = sorted(list(input()))
s = sinputlist[0]
for a in sinputlist[1:]:
    s += a
slist.append(s)
c = 0
for i in range(n-1):
    lastc = c
    sinputlist = sorted(list(input()))
    s = sinputlist[0]
    for a in sinputlist[1:]:
        s += a
    for j in range(len(slist)):
        if s == slist[j]:
            c += scount[j]
            scount[j] += 1
    if c == lastc:
        slist.append(s)
        scount.append(1)
print(c)


### FIXED CODE ###

import math
n = int(input())
l = ["".join(sorted(input())) for i in range(n)]
l.sort()
c = 0
b = l[0]
ans = 0
for s in l[1:]:
    if s == b:
        c += 1
    else:
        ans += c * (c + 1) * 0.5
        c = 0
    b = s
ans += c * (c + 1) * 0.5
print(int(ans))
### BUGGY CODE ###

N,K=map(int,input().split())
res=0
for i in range(N):
  tmp=1
  cnt=i
  while cnt<K:
    cnt*=2
    tmp/=2
  res+=tmp
res/=N
print(res)

### FIXED CODE ###

N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
  cnt=i
  pro=1
  while cnt<K:
    cnt*=2
    pro/=2
  pro/=N
  #print(pro)
  ans+=pro
print(ans)
### BUGGY CODE ###

n = int(input())
table = [[]]
for i in range(n):
  a = list(map(int, input().split()))
  table.append(a)
cursor = [0]*(n+1)
is_matched = set()
d = 0
match = 0
while match < n * (n-1) //2:
  now_match = match
  for i in range(1, n):
    if cursor[i] < n-1 and i not in is_matched:
      j = table[i][cursor[i]]
      if i < j and j not in is_matched and table[j][cursor[j]] == i :
        match += 1
        cursor[i] += 1
        is_matched.add(i)
        cursor[j] += 1
        is_matched.add(j)
  if now_match == match:
    print(-1)
    exit()
  d += 1
  is_matched.clear()
print(d)

### FIXED CODE ###

n = int(input())
table = [[] for _ in range(n+1)]
for i in range(1, n+1):
  a = list(map(int, input().split()))
  table[i] = a
cursor = [0]*(n+1)
is_matched = set()
d = 0
match = 0
while match < n * (n-1) //2:
  now_match = match
  for i in range(1, n):
    if cursor[i] < n-1 and i not in is_matched:
      j = table[i][cursor[i]]
      if i < j and j not in is_matched and table[j][cursor[j]] == i :
        match += 1
        cursor[i] += 1
        is_matched.add(i)
        cursor[j] += 1
        is_matched.add(j)
  if now_match == match:
    print(-1)
    exit()
  if d > 30000:
    print(499500)
    exit()  
  d += 1
  is_matched.clear()
print(d)
### BUGGY CODE ###

def sol():
    n=int(input())
    a=tuple(int(i) for i in input().split())
    chk=a.index(min(a))
    #for i in range(min(a[0],a[-1])*2,-1,-2):
    for i in range(a[chk]*2,-1,-2):
        ans=[0]*n
        ans[chk]=i
        f=1
        for k in range(1,n):
            j=(chk+k)%n
            t=(a[j-1]-ans[j-1]//2)*2
            if t>=0 and (t+ans[j-1])//2==a[j-1]:
                ans[j]=t
            else:
                f=0
                break
        #if f and ans[-1]//2+ans[-2]//2==a[-2] and ans[-1]//2+ans[0]//2==a[-1]:
        if f and ans[chk-1]//2+ans[chk-2]//2==a[chk-2] and ans[chk-1]//2+ans[chk]//2==a[chk-1]:
            print(*ans)
            exit()

if __name__=="__main__":
    sol()

### FIXED CODE ###

# from https://atcoder.jp/contests/abc133/submissions/6272850
n=int(input())
a=[int(i) for i in input().split()]
c=[0]
s=sum(a)

for i in range(2*n):
    c.append(c[-1]+a[(i*2+1)%n])
ans=[0]*n
for i in range(n):
    ans[i*2%n]=s-2*(c[i+n//2]-c[i])
print(*ans)
### BUGGY CODE ###

max = int(input())
orgList = list(map(int, input().split()))

result = 0;
for i in range(max):
    assertNo = orgList[i]
    sliceList = orgList[0:i+1]

    sliceList.sort()
    if sliceList[0] >= assertNo:
        result+= 1

print(result)


### FIXED CODE ###

max = int(input())
orgList = list(map(int, input().split()))
min = 999999999999

result = 0;
for i in range(max):
    assertNo = orgList[i]
    if min > orgList[i]-1:
        min = orgList[i]

    if min >= assertNo:
        result+= 1

print(result)
### BUGGY CODE ###

from collections import Counter
import bisect

def sortedexist(list,x):
    if bisect.bisect_left == bisect.bisect_right:
        return False
    else:
        return True

N = int(input())
A = [int(hoge) for hoge in input().split()]
C = Counter(A)
A.sort()
done = dict()
for a in A:
    done[a] = False
dp = [False] * (max(A) + 1)

for a in A:
    if done[a]:
        dp[a] = True
    elif dp[a] == False:
        for j in range(2,1 + (max(A) // a)):

            dp[a*j] = True
        done[a] = True
print(sum([dp[a] == False for a in A ]))

### FIXED CODE ###

N = int(input())
A = [int(hoge) for hoge in input().split()]
A.sort()
M = max(A)
dp = [False] * (M+ 1)
ans = 0
prev = -1
for a in A:
    if dp[a] == False:
        for j in range(2,1 + (M// a)):
            dp[a*j] = True
        if a != prev:
            ans += 1
        else:
            dp[a] = True
            ans -= 1
    prev = a
print(ans)
### BUGGY CODE ###

n=int(input())
a=[]
for _ in range(n):
  x=int(input())
  a.append(x)

for _ in range(n):
  b=a[0:_]+a[_+1:n]
  print(max(b))

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
f=b[-1]
s=b[-2]
for ans in a:
  if ans < f:
    print(f)
  else:
    print(s)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
cntA = [0 for _ in range(10**5)]
for i in range(10**5):
    if i in A:
        cntA[i] = A.count(i)
sumA = [0 for _ in range(10**5)]
sumA[0] = cntA[0]
sumA[1] = cntA[0] + cntA[1]
for i in range(2,10**5):
    sumA[i] = cntA[i] + cntA[i-1] + cntA[i-2]
print(max(sumA))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
cntA = [0 for _ in range(10**5)]
for a in A:
        cntA[a] += 1
sumA = [0 for _ in range(10**5)]
sumA[0] = cntA[0]
sumA[1] = cntA[0] + cntA[1]
for i in range(2,10**5):
    sumA[i] = cntA[i] + cntA[i-1] + cntA[i-2]
print(max(sumA))
### BUGGY CODE ###

def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	prev = max(A[1:])
	print(prev)
	for i in range(1, N-1):
		if A[i] != prev:
			prev = max(A[i-1], prev) 
			print(prev)
		else:
			prev = max(max(A[:i]), max(A[i+1:]))
			print(prev)

	print(max(A[:N-1]))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
	import sys
	import numpy as np
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	A = np.array(A)
	maxNum = np.max(A)
	maxIndex = np.where(A == A.max())[0]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(np.max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(np.max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(np.max(A[:maxIndex[0]]), np.max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)



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

n = int(input())
l = [0]
l.extend(list(map(int, input().split(" "))))

for d, i in enumerate(l):
    print(sum(map(lambda x: x == d + 1, l)))

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split(" ")))

h = [0] * n
for i in l:
    h[i - 1] += 1

for i in h:
    print(i)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    b = input()
    if b not in a:
        a += [b]
print(len(a))

### FIXED CODE ###

n = int(input())
a = []
ans = 0
for i in range(n):
    b = input()
    a+=[b]
c = sorted(a)
b = 0
for i in range(n-1):
    if c[i] == c[i+1]:
        b += 1

print(n-b)
### BUGGY CODE ###

import sys
from collections import Counter

n = int(sys.stdin.readline())
ct = Counter()
a_ls = dict()
for i in range(n):
    inp = [int(i) - 1 for i in sys.stdin.readline().split()]
    a_ls[i] = inp
cnt = 0
remain = list(range(n))
while True:
    combis = set()
    no_ls = []
    flg = False
    for i in remain:
        if len(a_ls[i]) == 0:
            no_ls.append(i)
            continue
        target = a_ls[i][0]
        if (i, target) in combis or (target, i) in combis:
            if len(a_ls[i]) > 0:
                a_ls[i].pop(0)
            if len(a_ls[target]) > 0:
                a_ls[target].pop(0)
            flg = True
        else:
            combis.add((i, target))
    remain = set(remain) - set(no_ls)
    if not flg:
        if not any([len(i) for i in a_ls.values()]):
            break
        cnt = -1
        break
    cnt += 1
print(cnt)

### FIXED CODE ###

import sys
from collections import Counter
import copy

n = int(sys.stdin.readline())
ct = Counter()
a_ls = dict()
for i in range(n):
    inp = [int(i) - 1 for i in sys.stdin.readline().split()]
    a_ls[i] = inp
cnt = 0
candidate = list(range(n))
rest = n * (n - 1) / 2
combis = set()
while rest:
    no_ls = []
    next_candidate = []
    flg = False
    for i in candidate:
        if len(a_ls[i]) == 0:
            continue
        target = a_ls[i][0]
        if (i, target) in combis or (target, i) in combis:
            next_candidate.append(i)
            next_candidate.append(target)
            rest -= 1
            if len(a_ls[i]) > 0:
                a_ls[i].pop(0)
            if len(a_ls[target]) > 0:
                a_ls[target].pop(0)
            flg = True
        else:
            combis.add((i, target))
    candidate = next_candidate
    if not flg:
        cnt = -1
        break
    cnt += 1
print(cnt)