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

from math import gcd
from copy import copy
#================================================
def GCD(A):
    n=len(A)
    if n==1:
        return A[0]

    return gcd(GCD(A[:n//2]),GCD(A[n//2:]))
#================================================
N=int(input())
A=list(map(int,input().split()))
B=copy(A)

M=0
for i in range(N):
    B[i]=0
    M=max(M,GCD(B))
    B[i]=A[i]

print(M)

### FIXED CODE ###

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

F=[0]*N
G=[0]*N

F[0]=A[0]
G[-1]=A[-1]

for i in range(1,N):
    F[i]=gcd(F[i-1],A[i])
    G[-(i+1)]=gcd(G[-i],A[-(i+1)])

F=[0]+F+[F[-1]]
G=[G[0]]+G+[0]

M=0
for i in range(N):
    M=max(M,gcd(F[i],G[i+2]))
print(M)
### BUGGY CODE ###

x,y = map(int,input().split())
count = 1
while(1):
     if count*x % y != 0:
         print(count*x)
         break

### FIXED CODE ###

x,y = map(int,input().split())
if x % y == 0:
    print("-1")
else:
    print(x)
### BUGGY CODE ###

n=int(input())
g=[]
for i in range(n):
  gi=input()
  x = gi in g
  if x == False:
    g.append(gi)
print(len(g))

### FIXED CODE ###

n=int(input())
g=[]
for i in range(n):
  gi=input()
  g.append(gi)  
g.sort()
count=1
for i in range(n-1):
  if g[i]!=g[i+1]:
    count+=1

print(count)
### BUGGY CODE ###

n = int(input())
a = []
count = 0
for i in range(n):
  item = input()
  if(item not in a):
    a.append(item)
    count+=1
print(count)


### FIXED CODE ###

n = int(input())
a = []
count = 0
for i in range(n):
  item = input()
  a.append(item)
print(len(list(set(a))))
### BUGGY CODE ###

from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().strip()
def mi():return map(int,input().split())
def li():return list(mi())
mod=1000000007

n=ii()
s=si()

    
l=0
r=n-1
ans=0
while(l<r):
    f=0
    for i in range(l,n):
        if s[i]=='W':
            l=i
            f=1
            break
    for i in range(r,-1,-1):
        if s[i]=='R':
            r=i
            break
    if(l>r or f==0):
        break
    ans+=1
    l+=1
    r-=1

print(ans)










### FIXED CODE ###

from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().strip()
def mi():return map(int,input().split())
def li():return list(mi())
mod=1000000007

n=ii()
s=si()

    
l=0
r=n-1
ans=0
while(l<r):
    f=0
    for i in range(l,n):
        if s[i]=='W':
            l=i
            f=1
            break
    f1=0
    for i in range(r,-1,-1):
        if s[i]=='R':
            r=i
            f1=1
            break
    if(l>=r or f==0 or f1==0):
        break
    ans+=1
    l+=1
    r-=1

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

import numpy as np
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])
A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True)[:min(X, K)])
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True)[:min(Y, K)])
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True)[:min(Z, K)])

out = sorted([sum(x) for x in itertools.product(A, B, C)], reverse=True)

for x in out[:K]:
    print(x)

### FIXED CODE ###

import numpy as np
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

tmp = {(0, 0, 0) : A[0] + B[0] + C[0]}
tmp_keys = [(0, 0 ,0)]
out = []

for i in range(K):
    (a, b, c),  p = max(tmp.items(), key=lambda x : x[1])
    out.append(tmp.pop((a, b, c)))

    keys = []
    if a < X - 1:
        keys.append((a+1, b, c))
    if b < Y - 1:
        keys.append((a, b+1, c))
    if c < Z - 1:
        keys.append((a, b, c+1))
    
    for key in keys:
        if key not in tmp_keys:
            tmp[key] = A[key[0]] + B[key[1]] + C[key[2]]
            tmp_keys.append(key)

for x in out:
    print(x)
### BUGGY CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
A=input()
B=input()
C=input()

a,b,c=len(A),len(B),len(C)

def f(X,Y):
  XY=[True]*(10**4)
  x,y=len(X),len(Y)
  for i in range(5000-y+1,5000+x):
    ret=True
    if i<=5000:
      for j in range(min(x,y+i-5000)):
        if X[j]=="?" or Y[j-i+5000]=="?" or X[j]==Y[j-i+5000]:
          continue
        else:
          ret=False
    else:
      for j in range(min(y,x-i+5000)):
        if Y[j]=="?" or X[j+i-5000]=="?" or Y[j]==X[j+i-5000]:
          continue
        else:
          ret=False
    XY[i]=ret
  return XY
AB=f(A,B)
BC=f(B,C)
AC=f(A,C)
ans=a+b+c
for i in range(5000-b-c,5000+a+c):
  for j in range(5000-b-c,5000+a+b):
    if -4000<=j-i<=4000:
      if AB[i] and AC[j] and BC[j-i+5000]:
        l=min(5000,i,j)
        r=max(i+b,j+c,5000+a)
        ans=min(ans,r-l)
    else:
      if AB[i] and AC[j]:
        l=min(5000,i,j)
        r=max(i+b,j+c,5000+a)
        ans=min(ans,r-l)
print(ans)


### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
A=input()
B=input()
C=input()

a,b,c=len(A),len(B),len(C)

def f(X,Y):
  XY=[True]*(10**4)
  x,y=len(X),len(Y)
  for i in range(5000-y+1,5000+x):
    ret=True
    if i<=5000:
      for j in range(min(x,y+i-5000)):
        if X[j]=="?" or Y[j-i+5000]=="?" or X[j]==Y[j-i+5000]:
          continue
        else:
          ret=False
    else:
      for j in range(min(y,x-i+5000)):
        if Y[j]=="?" or X[j+i-5000]=="?" or Y[j]==X[j+i-5000]:
          continue
        else:
          ret=False
    XY[i]=ret
  return XY
AB=f(A,B)
BC=f(B,C)
AC=f(A,C)
ans=a+b+c
for i in range(5000-b-c,5000+a+c):
  for j in range(5000-b-c,5000+a+b):
    if -4000<=j-i<=4000:
      if AB[i] and AC[j] and BC[j-i+5000]:
        l=min(5000,i,j)
        r=max(i+b,j+c,5000+a)
        ans=min(ans,r-l)
    else:
      if AB[i] and AC[j]:
        l=min(5000,i,j)
        r=max(i+b,j+c,5000+a)
        ans=min(ans,r-l)
print(ans)
### BUGGY CODE ###

from collections import defaultdict

def get_keys_of_max_value(d):
    v_max = 0
    keys = []
    for k, v in d.items():
        if v_max < v:
            v_max = v
            keys = [k]
        elif v_max == v:
            keys.append(k)
    return keys, v_max

h, w, m = map(int, input().split())
targets = [tuple(map(int, input().split())) for _ in range(m)]
n_r = defaultdict(int)
n_c = defaultdict(int)
for x, y in targets:
    n_r[x] += 1
    n_c[y] += 1

rows, n_r_max = get_keys_of_max_value(n_r)
columns, n_c_max = get_keys_of_max_value(n_c)

for r in rows:
    for c in columns:
        if (r, c) not in targets:
            print(n_r_max + n_c_max)
            break
    else:
        continue
    break
else:
    print(n_r_max + n_c_max - 1)


### FIXED CODE ###

from collections import defaultdict

def get_keys_of_max_value(d):
    v_max = 0
    keys = []
    for k, v in d.items():
        if v_max < v:
            v_max = v
            keys = [k]
        elif v_max == v:
            keys.append(k)
    return keys, v_max

h, w, m = map(int, input().split())
targets = {tuple(map(int, input().split())) for _ in range(m)}
n_r = defaultdict(int)
n_c = defaultdict(int)
for x, y in targets:
    n_r[x] += 1
    n_c[y] += 1

rows, n_r_max = get_keys_of_max_value(n_r)
columns, n_c_max = get_keys_of_max_value(n_c)

for r in rows:
    for c in columns:
        if (r, c) not in targets:
            print(n_r_max + n_c_max)
            break
    else:
        continue
    break
else:
    print(n_r_max + n_c_max - 1)
### BUGGY CODE ###

import numpy as np
R, B, G, N = (int(x) for x in input().split())
a = np.array([R, B, G])
a = np.sort(a)
b = a[2]
d = a[1]
f = a[0]
c = int(N / b)

count = 0

A = [N - b * i for i in range(c+1)]
C = list(map(int, A / d))

E = [A[k] - d * m for k in range(len(A)) for m in range(C[k] + 1)  ]
for g in range(len(E)):
    if E[g] % f == 0:
        count += 1
print(count)

### FIXED CODE ###

R, B, G, N = (int(x) for x in input().split())
a = [R, B, G]
a = sorted(a)
b = a[2]
d = a[1]
f = a[0]
c = int(N / b)

count = 0

for i in range(c + 1):
    n = N - b * i
    e = int(n / d)
    for j in range(e + 1):
        m = n - d * j
        if m % a[0] == 0:
            count += 1

print(count)
### BUGGY CODE ###

Q = 998244353
#import sys
#input = sys.stdin.readline
def main():
    A, B, C, D = map( int, input().split())
    dp = [[0]*3002 for _ in range(3001)]
    dp[C][D] = 1
    for a in range(C-1,A-1,-1):
        dp[a][D] = dp[a+1][D]*D%Q
    for b in range(D-1,B-1,-1):
        dp[C][b] = dp[C][b+1]*C%Q
    for a in range(C-1,A-1,-1):
        z = dp[a+1][D]*a%Q
        for b in range(D-1,B-1,-1):
            dp[a][b] = (b*dp[a+1][b] + z)%Q
            z = (z + dp[a+1][b])*a%Q
    # for i in range(C+1):
    #     print(dp[i][:D+1])
    print(dp[A][B])
if __name__ == '__main__':
    main()


### FIXED CODE ###

Q = 998244353
#import sys
#input = sys.stdin.readline
def main():
    A, B, C, D = map( int, input().split())
    dp = [[0]*3002 for _ in range(3001)]
    dp[C][D] = 1
    for a in range(C-1,A-1,-1):
        dp[a][D] = dp[a+1][D]*D%Q
    for b in range(D-1,B-1,-1):
        dp[C][b] = dp[C][b+1]*C%Q
    for a in range(C-1,A-1,-1):
        z = dp[a+1][D]*a%Q
        for b in range(D-1,B-1,-1):
            dp[a][b] = (b*dp[a+1][b] + z)%Q
            z = (z + dp[a+1][b])*a%Q
    # for i in range(C+1):
    #     print(dp[i][:D+1])
    print(dp[A][B])
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import collections
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a = a[::-1]
x,answer,num = collections.Counter(a),1,-1
while a != []:
	if x[a[0]]>=4 and num==-1:
		print(a[0]**2)
		break
	elif x[a[0]]>=2:
		answer *= a[0]
		num += 1
		if num==1:
			print(answer)
			break
	a = a[x[a[0]]:]
	if a == []:
		print(0)

### FIXED CODE ###

import collections
n = int(input())
a = [int(i) for i in input().split()]
x,y,z = collections.Counter(a),[0],[0,0]
for i in x.keys():
	if x[i]>=4:
		y.append(i)
	if x[i]>=2:
		z.append(i)
y,z = sorted(y),sorted(z)
print(max(y[-1]**2,z[-1]*z[-2]))
### BUGGY CODE ###

from math import factorial
mod=10**9+7
def cmb(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)%mod

n,m,k=map(int,input().split())
print(((pow(m,2,mod)*cmb(n*m-2,k-2)*sum((n-i)*i for i in range(1,n)))+pow(n,2,mod)*cmb(n*m-2,k-2)*sum((m-i)*i for i in range(1,m)))%mod)

### FIXED CODE ###

mod=10**9+7
def mod_combination(n, k, mod):
    def ext_gcd(a, b):
        if b == 0:return a, 1, 0
        else:d,x,y = ext_gcd(b,a%b);x-=(a//b)*y 
        return d,y,x
    p,q=1,1
    for i in range(n-k+1,n+1):
        p=(p*i)%mod
    for i in range(2,k+1):
        q=(q*i)%mod
    return int(p*(ext_gcd(q, mod)[1]%mod)%mod)


n,m,k=map(int,input().split())
print(((pow(m,2,mod)*mod_combination(n*m-2,k-2,mod)*sum((n-i)*i%mod for i in range(1,n))%mod)+pow(n,2,mod)*mod_combination(n*m-2,k-2,mod)*sum((m-i)*i%mod for i in range(1,m))%mod)%mod)
### BUGGY CODE ###

n=int(input())
lst=[]
for i in range(1,n):
    #if i**2>n:
    #    break
    if n%i==0:
        lst.append(i+n//i)
print(min(lst)-2)



### FIXED CODE ###

n=int(input())
lst=[]
for i in range(1,n):
    if i**2>n:
        break
    if n%i==0:
        lst.append(i+n//i)
print(min(lst)-2)
### BUGGY CODE ###

from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
ans = N
l = 1
r = 10**5
while l != r or (l == r and C[l] > 1):
    while C[l] <= 1:
        l += 1
    while C[r] <= 1:
        r -= 1

    if l != r:
        res = min(C[l], C[r]) - 1
    else:
        res = C[l]//2
    C[l] -= res
    C[r] -= res
    ans -= 2*res
print(ans)


### FIXED CODE ###

from collections import Counter

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = len(C)
if (N-ans) % 2 == 1:
    ans -= 1
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

from copy import copy


def min_max_try(n, dams):
    mt_min = [0] * n
    mt_max = copy(dams)

    while True:
        # max -> min
        update = False
        for i in range(n):
            tmp_min = dams[i] - mt_max[i]
            if tmp_min > mt_min[(i+1) % n]:
                mt_min[(i+1) % n] = tmp_min
                update = True
            tmp_min = dams[i] - mt_max[(i+1) % n]
            if tmp_min > mt_min[i]:
                mt_min[i] = tmp_min
                update = True
        if not update:
            return mt_min, mt_max

        # min -> max
        update = False
        for i in range(n):
            tmp_max = dams[i] - mt_min[i]
            if tmp_max < mt_max[(i+1) % n]:
                mt_max[(i+1) % n] = tmp_max
                update = True
            tmp_max = dams[i] - mt_min[(i+1) % n]
            if tmp_max < mt_max[i]:
                mt_max[i] = tmp_max
                update = True
        if not update:
            return mt_min, mt_max


def check_answer(pos, val, n, dams):
    mt = [val] * n
    for i in range(n-1):
        mt[(pos+i+1) % n] = dams[(pos+i) % n] - mt[(pos+i) % n]
    ok = mt[pos] + mt[(pos+n-1) % n] == dams[(pos+n-1) % n]
    return ok, mt


def solv(n, dams):
    # print(dams)
    mt_min, mt_max = min_max_try(n, dams)
    # print(mt_min, mt_max)

    idx = 0
    diff = mt_max[0] - mt_min[0]
    for i in range(1, n):
        if mt_max[i] - mt_min[i] < diff:
            diff = mt_max[i] - mt_min[i]
            idx = i

    for val in range(mt_min[idx], mt_max[idx]+1):
        ok, mt = check_answer(idx, val, n, dams)
        if ok:
            return ' '.join([str(m*2) for m in mt])

    return 'Error'


if __name__ == '__main__':

    n = int(input())

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

    ans = solv(n, dams)
    print(ans)


### FIXED CODE ###

#!/usr/bin/env python3


def solv(n, dams):
    m = (sum(dams[::2]) - sum(dams[1::2])) // 2
    ans = [m*2]
    for i in range(n-1):
        m = dams[i] - m
        ans.append(m*2)
    return ans


if __name__ == '__main__':

    n = int(input())
    dams = [int(a) for a in input().split()]

    ans = solv(n, dams)

    print(' '.join([str(a) for a in ans]))
### BUGGY CODE ###

n = int(input())
x = []
y = []
ans = 0
for i in range(n):
    x1, y1 = map(int, input().split())
    x.append(x1)
    y.append(y1)
for i in range(n-1):
    for j in range(i,n):
        m = abs(x[i]-x[j]) + abs(y[i]-y[j])
        ans = max(ans, m)
print(ans)

### FIXED CODE ###

n = int(input())
u = []
v = []
ans = 0
for i in range(n):
    x, y = map(int, input().split())
    u.append(x+y)
    v.append(x-y)
ans = max(max(u) - min(u), max(v) - min(v))
print(ans)
### BUGGY CODE ###

s= input();
q = int(input());
while(q>0):
    q-=1;
    ls = list(map(str,input().split(" ")));
    if(ls[0]=='1'):
        s=s[::-1];
    else:
        if(ls[1]=='1'):
            s=ls[2]+s;
        else:
            s=s+ls[2];
print(s)

### FIXED CODE ###

s= input();
q = int(input());
flag = 0;
fornt = "";
back = "";
while(q>0):
    q-=1;
    ls = list(map(str,input().split(" ")));
    if(ls[0]=='1'):
        flag +=1;
    else:
        if(flag%2 == 1):
            if(ls[1]=='2'):
                fornt=ls[2]+fornt;
            else:
                back=back+ls[2];
        else:
            
            if(ls[1]=='1'):
                fornt=ls[2]+fornt;
            else:
                back=back+ls[2];
s = fornt+s+back
if(flag%2==0):
    print(s);
else:
    print(s[::-1])
### BUGGY CODE ###

n,k=map(int,input().split())
h=[list(map(int,input().split())) for _ in range(n)]

import itertools
result = 10**9
h_sorted = sorted(h)
for i in range(n-k+1):
  k_arr = h_sorted[i:i+k]
  k_arr = list(itertools.chain.from_iterable(k_arr))
  result = min(result, k_arr[k-1]-k_arr[0])

print(result)

### FIXED CODE ###

n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]

h.sort()
result = 10**9
for i in range(n-k+1):
  result = min(result, h[i+k-1] - h[i])

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

import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = [list(map(int, readline().split())) for _ in range(n)]
    for i in range(n):
        for j in range(n - 1):
            a[i][j] -= 1
    ls = [0] * n
    ql = collections.deque()
    for i in range(n):
        ql.append([0, i])

    for i in range(10 ** 10):
        fq = [True] * n
        while ql:
            d, ps = ql.popleft()
            if d == i:
                if fq[ps]:
                    nw = a[ps][ls[ps]]
                    if fq[nw]:
                        rw = a[nw][ls[nw]]
                        if ps == rw:
                            ls[ps] += 1
                            ls[nw] += 1
                            if ls[ps] < n - 1:
                                ql.append([d+1, ps])
                            if ls[nw] < n - 1:
                                ql.append([d+1, nw])
                            fq[nw] = False
                            fq[ps] = False
            else:
                ql.appendleft([d, ps])
                break
        if len(ql) == 0 or sum(ls) == n * (n - 1):
            print(i + 1 if sum(ls) == n * (n - 1) else -1)
            exit()


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ad = [0] * n
    dq = collections.deque([[0, i + 1] for i in range(n)])
    for i in range(10 ** 15):
        fd = {}
        while True:
            if len(dq) != 0:
                d, q = dq.popleft()
                q -= 1
                if d <= i:
                    if ad[q] < n - 1:
                        qq = a[q][ad[q]] - 1
                        tq = a[qq][ad[qq]] - 1
                        if q == tq and qq not in fd and tq not in fd:
                            ad[qq] += 1
                            ad[tq] += 1
                            if ad[qq] < n - 1:
                                dq.append([d + 1, qq + 1])
                            if ad[tq] < n - 1:
                                dq.append([d + 1, tq + 1])
                            fd[qq] = 0
                            fd[tq] = 0
                else:
                    dq.append([d, q + 1])
                    break
            else:
                break
        if len(dq) == 0:
            b = True
            for v in ad:
                if v != n - 1:
                    b = False
                    break
            if b:
                print(i + 1)
                exit()
            else:
                print(-1)
                exit()


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

import math
def calc_factors(n):
    factors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            j = n // i
            if j != i: factors.append(j)
            factors.append(i)
    return factors

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

ans = 0
done = set()
for i in range(n):
    num = a[i]
    if i < n-1 and a[i] == a[i+1]:
        done.add(num)
        continue
    factors = calc_factors(num)
    for f in factors:
        if f in done:
            break
    else:
        ans += 1
    done.add(num)
print(ans)


### FIXED CODE ###

import math
def sieve(n, done):
    for i in range(n, 10**6+1, n):
        done[i] = 1

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

ans = 0
done = [0] * (10 ** 6 + 1)

for i in range(n):
    num = a[i]
    if i < n-1 and a[i] == a[i+1]:
        if i > 0 and a[i] == a[i-1]:
            continue
        sieve(num, done)
        continue
    
    if not done[num]:
        sieve(num, done)
        ans += 1

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

n,q=map(int,input().split())
s=input()
lr=[]
for _ in range(q):
  l,r=map(int,input().split())
  lr.append([l,r])
def ans(x):
  l=lr[x][0]
  r=lr[x][1]
  s_x=s[l-1:r]
  n=len(s_x)
  a=0
  for i in range(n-1):
    if s_x[i]=='A' and s_x[i+1]=='C':
      a+=1
  return a
for i in range(q):
  print(ans(i))

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
lr=[]
for _ in range(q):
  l,r=map(int,input().split())
  lr.append([l,r])

t=[0]*n
for i in range(n-1):
  if s[i:i+2]=='AC':
    t[i+1]=t[i]+1
  else:
    t[i+1]=t[i]
for i in range(q):
  l=lr[i][0]
  r=lr[i][1]
  print(t[r-1]-t[l-1])
### BUGGY CODE ###

N, Q = map(int, input().split())
S = list(input())
holder = []
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        holder.append(i)
for _ in range(Q):
    l, r = map(int, input().split())
    count = 0
    for index in holder:
        if index+1 >= l and index+2 <= r:
            count += 1
    print(count)


### FIXED CODE ###

N, Q = map(int, input().split())
S = list(input())
holder = set()
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        holder.add(i+1)

# 累積和でどうぞ
prefix = [0 for _ in range(N+1)]
for i in range(1, N+1):
    if i-1 in holder:
        prefix[i] = prefix[i-1] + 1
    else:
        prefix[i] = prefix[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(prefix[r] - prefix[l])
### BUGGY CODE ###

def check(a,cnt):
  b = [int(x)%2 for x in a]
  if 1 in b:
    return 0,cnt
  else :
    cnt +=1
    b = [int(x)/2 for x in a]
    return 1,cnt
 
N = input()
a = input().split()
cnt = 0
m = 1
while(m != 0):
  m,cnt = check(a,cnt)
  if m == 0:
    print(cnt)
  else :
    continue

### FIXED CODE ###

def check(a,cnt):
  c = [int(x)%2 for x in a]
  if 1 in c:
    return 0,cnt,a
  else :
    cnt +=1
    b = [int(x)/2 for x in a]
    return 1,cnt,b
 
N = input()
a = input().split()
cnt = 0
m = 1
while(m != 0):
  m,cnt,a = check(a,cnt)
  if m == 0:
    print(cnt)
  else :
    continue
### BUGGY CODE ###

#D
n,m = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)

while m>0:
    a[0] //= 2
    m -= 1
    a.sort(reverse=True)
    
print(sum(a))

### FIXED CODE ###

#優先度付きキュー -> 最小値をO(logN)で取り出す
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))

a = [-x for x in a]

#aを優先度付きキューに変更
heapq.heapify(a)

for _ in range(m):
   
    tmp = heapq.heappop(a)
    tmp = (-tmp // 2) * -1
    heapq.heappush(a,tmp)
        
    
print(sum(a) * -1)
### BUGGY CODE ###

def abc094C():
    n = int(input())
    x = input().split()
    x = list(map(int, x))
    y = x.copy()
    y.sort()
    nums = y[int(n / 2 - 1): int(n / 2 + 1)]
    for i in range(n):
        y = x.copy()
        tf = nums[0] >= y[i]
        del y[i]
        y.sort()
        print(nums[tf])


abc094C()

### FIXED CODE ###

def abc094C():
    n = int(input())
    x = input().split()
    x = list(map(int, x))
    y = x.copy()
    y.sort()
    nums = y[int(n / 2 - 1): int(n / 2 + 1)]
    for i in range(n):
        tf = nums[0] >= x[i]
        print(nums[tf])


abc094C()
### BUGGY CODE ###

import sys
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

for i in range(1,n+1):
    print(np.count_nonzero(a==i))


### FIXED CODE ###

import sys
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

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

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = []
    r = []
    
    for i in range(n):
        l.append((i + 1) + a[i])
        r.append((i + 1) - a[i])
        
    cnt = 0
    for i in l:
        for j in r:
            if i == j:
                cnt += 1



    
    return cnt




print(solve())


### FIXED CODE ###

from collections import*
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = []
    r = []
    for i, j in enumerate(a):
        l += [i + j]
        r += [i - j]

    cnt = 0
    l = Counter(l)
    for r in r:
        cnt += l.get(r, 0)

    
    return cnt




print(solve())