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

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

d0 = [0]*100
d1 = [0]*100
for i in range(n):
    for j in range(61):
        if a[i] & (1<<j):
            d1[j] += 1
        else:
            d0[j] += 1

x = 1
ans = 0
mod = 10**9+7
for i in range(100):
    ans += x * d0[i] * d1[i] %mod
    x = x * 2 % mod
    ans %= mod
print(ans)

### FIXED CODE ###

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

d0 = [0]*100
d1 = [0]*100
for i in range(n):
    for j in range(61):
        if a[i] & (1<<j):
            d1[j] += 1
        else:
            d0[j] += 1

x = 1
ans = 0
mod = 10**9+7
for i in range(100):
    ans += x * d0[i] * d1[i] %mod
    x = x * 2 % mod
    ans %= mod
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)


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

    def dp(i, j):
        if i == 0 and j == 0:
            return 0
        if i == 0 and j == 1:
            return -float('inf')
        if j == 0:
            return max(dp(i - 1, 0) + a[i - 1], dp(i - 1, 1) - a[i - 1])
        if j == 1:
            return max(dp(i - 1, 0) - a[i - 1], dp(i - 1, 1) + a[i - 1])

    score = dp(n, 0)

    print(score)


main()


### FIXED CODE ###

def main():
    n = int(input())
    aa = list(map(int, input().split()))

    pos = [0] * n
    neg = [0] * n

    pos[0] = aa[0]
    neg[0] = -aa[0]

    for i, a in enumerate(aa[1:-1], start=1):
        pos[i] = max(pos[i - 1] + a, neg[i - 1] - a)
        neg[i] = max(pos[i - 1] - a, neg[i - 1] + a)

    pos[n - 1] = pos[n - 2] + aa[n - 1]
    neg[n - 1] = neg[n - 2] - aa[n - 1]

    score = max(pos[n - 1], neg[n - 1])

    print(score)


main()
### BUGGY CODE ###

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

im = iter(m)
UVW = list(zip(im, im, im))

# set default color to -1

colors = {i:-1 for i in range(1,N+1)}
u,v,w = UVW[0]
colors[u] = 0

def opposite(u, v):
    if v == -1:
        return u
    if v == 0:
        return 1
    if v == 1:
        return 0

def same(u, v):
    if v == -1:
        return u
    else:
        return v

while -1 in colors.values():
    next_UVW = []
    for u, v, w in UVW:
        if colors[u] == -1 and colors[v] == -1:
            next_UVW.append((u, v, w))
            continue

        if w % 2 == 0:
            colors[u] = same(colors[u], colors[v])
            colors[v] = same(colors[v], colors[u])

        if w % 2 == 1:
            colors[u] = opposite(colors[u], colors[v])
            colors[v] = opposite(colors[v], colors[u])

        if colors[u] == -1 or colors[v] == -1:
            next_UVW.append((u,v,w))

    UVW = next_UVW



for i in range(1, N+1):
    print(colors[i])

### FIXED CODE ###

N = int(input())

u_list = []
v_list = []
w_list = []

for _ in range(N-1):
  u, v, w = map(int, input().split())
  u_list.append(u-1)
  v_list.append(v-1)
  w_list.append(w)
  
color_dict = dict()
uvw_list = list(zip(u_list, v_list, w_list))
color_dict[u_list[0]] = 1

def eval_single(u, v, w, color_dict):
  skip = True

  if u in color_dict:
    color_dict[v] = assign_color(color_dict[u], w)
    skip = False
    
  if v in color_dict:
    color_dict[u] = assign_color(color_dict[v], w)
    skip = False
    
  return skip, color_dict
  

def assign_color(color, w):
  if w%2==0:
    return color
  else:
    return color*(-1)+1
  
while True:
  ind_list = []
  for ind, (u, v, w) in enumerate(uvw_list):
    skip, color_dict = eval_single(u, v, w, color_dict)
    
    if skip:
      ind_list.append(ind)

  uvw_list = [uvw_list[ind] for ind in ind_list]
  
  if len(color_dict) == N:
    break

for i in range(N):
  print(color_dict[i])
### BUGGY CODE ###

#import numpy as np
n=int(input())+1
yueg=[0]*(n)
for i in range(1,n):
  j=0
  while j < n:
    yueg[j]+=1
    j+=i
  yueg[i]*=i
r=0  
#yueg=np.array(yueg)
#ka=np.array([k for k in range(0,n)])
#r=np.sum(yueg*ka)
print(sum(yueg)-yueg[0])

### FIXED CODE ###

#import numpy as np
def main():
  n=int(input())+1
  yueg=[0]*(n)
  for i in range(1,n):
    j=0
    while j < n:
      yueg[j]+=1
      j+=i
    yueg[i]*=i
  r=0  
#yueg=np.array(yueg)
#ka=np.arange(n)
#r=np.sum(yueg*ka)
  print(sum(yueg)-yueg[0])
main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)


MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def dfs(pv, v):
    global MOD
    for e in edge[v]:
        if e != pv and e not in V[v].keys():
            nc, nvar = dfs(v, e)
            V[v][e] = (nc, nvar)
    childs = 0
    var = 1
    for key in [i for i in V[v].keys() if i != pv]:
        cn, cvar = V[v][key]
        childs += cn
        var *= cvar
        var %= MOD
        var *= invs[cn]
        var %= MOD
    var *= modFacts[childs]
    var %= MOD
    return childs + 1, var


N = int(input())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

modFacts, invs = prepare(N)

V = [{} for _ in range(N)]
for i in range(N):
    dfs(-1, i)


for i in range(N):
    ans = 1
    cnt = 0
    for n, var in V[i].values():
        ans *= var
        ans %= MOD
        ans *= invs[n]
        ans %= MOD
        cnt += n
    ans *= modFacts[cnt]
    print(ans % MOD)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)


MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def dfs(v):
    global MOD
    childs = 0
    var = 1
    for e in edge[v]:
        if path[e] == 0:
            path[e] = 1
            nc, nvar = dfs(e)
            childs += nc
            V[v][e] = (nc, nvar)
            var *= nvar
            var %= MOD
            var *= invs[nc]
            var %= MOD
    var *= modFacts[childs]
    var %= MOD
    return childs + 1, var


def dfs2(v):
    global MOD
    tNodes = 0
    tVar = 1
    for n, var in V[v].values():
        tNodes += n
        tVar *= var
        tVar %= MOD
        tVar *= invs[n]
        tVar %= MOD
    tVar *= modFacts[tNodes]
    tVar %= MOD
    dp[v] = tVar

    for e in edge[v]:
        if dp[e] == 0:
            eNodes, eVar = V[v][e]
            nVar = (tVar * invs[tNodes] * modFacts[eNodes] * modFacts[tNodes - eNodes]) % MOD
            nVar *= pow(eVar, MOD - 2, MOD)
            nVar %= MOD
            V[e][v] = (tNodes - eNodes + 1, nVar)
            dfs2(e)


N = int(input())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

modFacts, invs = prepare(N)

V = [{} for _ in range(N)]
path = [0] * N
dp = [0] * N
path[0] = 1
dfs(0)
dfs2(0)


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

# -*- coding: UTF-8 -*-

n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n-1):
    l = a[:i] + a[i+1:]
    print(max(l))

print(max(a[:n]))


### FIXED CODE ###

# -*- coding: UTF-8 -*-

n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a,reverse=True)

p = a.index(max(a))

for i in range(n):
    if i == p:
        print(b[1])
    else:
        print(b[0])
### BUGGY CODE ###

L, R = map(int, input().split())
output = 2018

for i in range(L, R + 1):
    for k in range(i + 1, R + 1):
        if output > i * k % 2019:
            output = i * k % 2019
            
print(output)

### FIXED CODE ###

L, R = map(int, input().split())
output = 2018


for i in range(L, R + 1):
    for k in range(i + 1, R + 1):
        if output == 0:
            break

        if output > i * k % 2019:
            output = i * k % 2019
    else:
        continue
    break

print(output)
### BUGGY CODE ###

N = int(input())
P = list(map(int,input().split()))
count = 0
for i in range(N):
    flag = True
    for j in range(i):
        if P[i] > P[j]:
            flag = False
            break
    if flag: count += 1
print(count)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
count = 0
pmin = P[0]
for i in range(N):
    if pmin > P[i]: pmin = P[i]
    if pmin >= P[i]: count += 1
print(count)
### BUGGY CODE ###

import math
import random
import sys
import heapq
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, UserString
from functools import lru_cache, cmp_to_key, reduce
from itertools import (chain, combinations, combinations_with_replacement,
                       permutations, product)

sys.setrecursionlimit(10**7)
MAX_INT = 2**62-1

input = sys.stdin.buffer.readline

@lru_cache(None)
def gcd(a, b):
    if not b:
        return a
    return gcd(b, a%b)

if __name__ == "__main__":
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans += gcd(i, gcd(j, k))
    print(ans)


### FIXED CODE ###

import math
import random
import sys
import heapq
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, UserString
from functools import lru_cache, cmp_to_key, reduce
from itertools import (chain, combinations, combinations_with_replacement,
                       permutations, product)

sys.setrecursionlimit(10**7)
MAX_INT = 2**62-1

input = sys.stdin.buffer.readline

@lru_cache(None)
def gcd(a, b):
    if not b:
        return a
    return gcd(b, a % b)

if __name__ == "__main__":
    n = int(input())
    ans = (n + 1) * n // 2

    for i in range(1, n+1):
        for j in range(i+1, n+1):
            ans += gcd(j, i) * 6
            for k in range(j+1, n+1):
                ans += gcd(i, gcd(j, k)) * 6
    print(ans)
### BUGGY CODE ###

import sys
from bisect import bisect_left,bisect

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n,m=map(int,input().split())

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

for i in range(m):
	A.insert(bisect_left(A,max(A)//2),max(A)//2)
	del A[n]
	
print(sum(A))

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
a = list(map(lambda x: x*(-1), a))  # 各要素を-1倍

heapq.heapify(a)

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

import sys

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

ans = [[E[i][j] for j in range(N)] for i in range(N)]

for k in range(N):
	for i in range(N):
		for j in range(N):
			direct = E[i][j]
			detour = E[i][k]+E[k][j]
			if direct < detour:
				continue
			elif direct > detour:
				print(-1)
				sys.exit()

			else:
				if i != k and j != k:
					ans[i][j] = 0
					ans[j][i] = 0

answer = 0
for a in ans:
	answer += sum(a)

print(answer//2)

### FIXED CODE ###

import sys

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

inf = float('inf')
for i in range(N):
	E[i][i] = inf

for k in range(N):
	for i in range(N):
		if i == k:
			continue
		for j in range(N):
			if k == j or i == j:
				continue
			direct = E[i][j]
			detour = E[i][k]+E[k][j]
			if direct == inf or detour == inf:
				continue

			if direct > detour:
				print(-1)
				sys.exit()

			elif direct == detour:		
				E[i][j] = inf
				E[j][i] = inf

answer = 0
for i in range(N):
	for j in range(N):
		if E[i][j] == inf:
			continue
		
		answer += E[i][j]

print(answer//2)
### BUGGY CODE ###

#https://atcoder.jp/contests/abc152/tasks/abc152_c

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(n):
    flag=1
    for j in range(i):
        if p[i]>p[j]:
            flag=0
            break
    if flag==1:
        count+=1
print(count)


### FIXED CODE ###

#https://atcoder.jp/contests/abc152/tasks/abc152_c

n=int(input())
p=list(map(int,input().split()))
count=1
min_num=p[0]
for i in range(1,n):
    min_num=min(p[i-1],min_num)
    if p[i]<=min_num:
        count+=1
print(count)
### BUGGY CODE ###

import numpy as np

def main():
    x = int(input())
    a = -119
    while True:
        for b in range(-120,120):
            if a ** 5 - b ** 5 == x:
                print(a, b)
                break
        a += 1


if __name__ == '__main__':
    main()


### FIXED CODE ###



def main():
    x = int(input())
    for a in range(-120, 120):
        for b in range(-120, 120):
            if a ** 5 - b ** 5 == x:
                print(a, b)
                break
        else:
            continue
        break


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

import sys
import copy

fline = input().rstrip().split(' ')
a, b, x = int(fline[0]), int(fline[1]), int(fline[2])

count = 0
for i in range(a, b+1):
    if i%x==0:
        count = count+1
print(count)

### FIXED CODE ###

import sys
import copy

fline = input().rstrip().split(' ')
a, b, x = int(fline[0]), int(fline[1]), int(fline[2])

y = (a-1)//x
z = b//x
print(z-y)
### BUGGY CODE ###

def chmin(a, b):
    if a > b:
        return b
    return a

N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [float('inf')]*N
dp[0] = 0

for i in range(N-1):
    k = min(K, N-(i+1))
    for j in range(1, k+1):
        dp[i+j] = chmin(dp[i+j], dp[i] + abs(H[i+j] - H[i]))

print(dp[-1])

### FIXED CODE ###

def chmin(a, b):
    if a > b:
        return b
    return a

N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [float('inf')]*N
dp[0] = 0

for i in range(N-1):
    k = min(K, N-(i+1))
    for j in range(1, k+1):
        dp[i+j] = chmin(dp[i+j], dp[i] + abs(H[i+j] - H[i]))

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

import sys
import math

N = int(input())

str_list = list(map(int,input().split()))

sum0 = 1

for n in range(0,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print('-1')
else:
    print(sum0)

### FIXED CODE ###

N = int(input())

str_list = list(map(int,input().split()))

sum0 = str_list[0]

for n in range(0,N):
    if str_list[n] == 0:
        sum0 = 0

for n in range(1,N):
    if sum0 == 0:
        break
    sum0 = sum0 * str_list[n]
    if sum0 > 10 ** 18:
        sum0 = -1
        break

print(sum0)
### BUGGY CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
# list(map(int, input().split()))
mod = 10 ** 9 + 7
# https://atcoder.jp/contests/abc141/tasks/abc141_d

# Nは人、Mは関係の数
N, M, K = getNM()
friend = [[] for i in range(N)]
for i in range(M):
    a, b = getNM()
    friend[a - 1].append(b - 1)
    friend[b - 1].append(a - 1)
blocked = [[] for i in range(N)]
for i in range(K):
    a, b = getNM()
    blocked[a - 1].append(b - 1)
    blocked[b - 1].append(a - 1)
def matcher(n):
    ignore = [0] * (N + 1)
    ignore[n] = 1
    pos = deque([n])
    setfriend = set(friend[n])
    setblocked = set(blocked[n])
    res = set()
    while len(pos) > 0:
        u = pos.popleft()
        for i in friend[u]:
            if ignore[i] > 0:
                continue
            ignore[i] = 1
            if not i in (setfriend | setblocked):
                res.add(i)
            pos.append(i)
    return len(res)
ans = []
for i in range(N):
    ans.append(matcher(i))
print(*ans)

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
# list(map(int, input().split()))
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

N, M, K = getNM()

# グループ分けをして解いていく
U = UnionFind(N)

friendlist = [getList() for i in range(M)]
blockedlist = [getList() for i in range(K)]
# friendlist内のa, bを繋いでいく
for a, b in friendlist:
    U.union(a - 1, b - 1)

friends = [0] * (N + 1)
blocks = [0] * (N + 1)

# 「同じグループ内に」友達、ブロックが何人いるか
for a, b in friendlist:
    if U.same(a - 1, b - 1):
        friends[a - 1] += 1
        friends[b - 1] += 1
for a, b in blockedlist:
    if U.same(a - 1, b - 1):
        blocks[a - 1] += 1
        blocks[b - 1] += 1

ans = []
for i in range(N):
    # U.size: グループの大きさ
    cnt = U.size(i) - friends[i] - blocks[i] - 1
    ans.append(cnt)
print(*ans)
### BUGGY CODE ###

def main():
    import collections
 
    H, W, M_ko = map(int, input().split())
 
    zahyou = [[0 for i in range(W)] for j in range(H)]
    zahyou_H = [0 for i in range(H)]
    zahyou_W = [0 for i in range(W)]
    
 
    for i in range(M_ko):
        height, width = map(int, input().split())
 
        zahyou[height - 1][width - 1] = 1
        
        zahyou_H[height - 1] += 1
        zahyou_W[width - 1] += 1
 
    CTR_H = collections.Counter(zahyou_H)
    CTR_W = collections.Counter(zahyou_W)
 
    max_h = max(zahyou_H)
    max_w = max(zahyou_W)
 
    len_h = CTR_H[max_h]
    len_w = CTR_W[max_w]
 
    index_h = [i for i, x in enumerate(zahyou_H) if x == max_h]
    index_w = [i for i, x in enumerate(zahyou_W) if x == max_w]
 
 
    maxi = max_h + max_w
    FLAG = False
 
 
    if (len_h == 1 and len_w == 1):    
        maxi -= zahyou[index_h[0]][index_w[0]]
 
 
    else:
        for i in range(len_h):        
            for j in range(len_w):
                val = zahyou[index_h[i]][index_w[j]]
                
                if (val == 0):
                    FLAG = True
                    break
        
        if (not FLAG):
            maxi -= 1
 
    print(maxi)
 
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np
import numba
import sys
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


@njit((i8, i8, i8[:]), cache=True)
def main(Height, Width, XY):
    UP = 300010
    row = np.zeros(UP, np.int64)
    col = np.zeros(UP, np.int64)
    
    for i in range(0, len(XY), 2):
        x, y = XY[i:i + 2] - 1
        row[x] += 1
        col[y] += 1
    
    row_max = row.max()
    col_max = col.max()

    judge = np.sum(row == row_max) * np.sum(col == col_max)

    for i in range(0, len(XY), 2):
        x, y = XY[i:i + 2] - 1
        
        if (row[x] == row_max and col[y] == col_max):
            judge -= 1
    
    summ = row_max + col_max
    
    return (summ if judge else summ - 1)


Height, Width, M_ko = map(int, readline().split())
XY = np.array(read().split(), np.int64)

ans = main(Height, Width, XY)
print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(1,n+1):
  ans.append(a.index(i)+1)
for i in range(n):
  if(i<n-1):
     print(ans[i],end=" ")
  else:
    print(ans[i])

### FIXED CODE ###

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

n = int(input())
h = list(map(int,input().split()))
cnt = 0
for i in range(n-1):
    j = i
    cnt_ = 0
    while h[j] >= h[j+1]:
        cnt_ += 1
        j += 1
        if j == n-1:
            break
    if cnt_ > cnt:
        cnt = cnt_
print(cnt)

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
cnt = 0
cnt_ = 0
for i in range(n-1):
    if h[i] < h[i+1]:
        cnt_ = 0
    else:
        cnt_ += 1
        if cnt < cnt_:
            cnt = cnt_
print(cnt)
### BUGGY CODE ###

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

for i in range(0,N):
	li[i] = li[i] - i -1
a = []
for i in range(min(li),max(li)+1):
	k = 0
	for j in range(0,N):
		k = k + abs(li[j]-i)
	a.append(k)
print(min(a))

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
for i in range(0,len(a)):
    a[i] -= (i+1)
a.sort()
b = [ abs(x  - (a[n//2])) for x in a]
print(sum(b))
### BUGGY CODE ###

N = int(input())
a = (int(x) for x in input().split())
number =1

for i in a:
    if number==0:
        exit()
    number *= i
    

if number>10**18:
    number = -1

print(number)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
number =1

if 0 in a:
    print(0)
    exit()

for i in a:
    number *= i
    if number > 10**18:
            print(-1)
            exit()

print(number)
### BUGGY CODE ###

N = int(input())
An = input().split()
c = 0
for i in range(N):
    An[i] = int(An[i])
for X in range(1,N):    
    for i in range(N):
        if An[i] + i == X:
            for k in range(N):
                if k - An[k] == X:
                    c = c + 1
print(c)

### FIXED CODE ###

from collections import Counter
N = int(input())
An = list(map(int,input().split()))
c = 0
Bn = []
Cn = []
for k in range(N):    
    Bn.append(An[k]+k)
    Cn.append(k-An[k])
Cj = Counter(Cn)
for i in Bn:
    c+=Cj[i]
print(c)
### BUGGY CODE ###

N,A,B=map(int, input().split())
turn=0
while (A!=1 and B!=N) or turn==0:
  if A!=B-1:
    A+=1
  else:
      A=A-1
  if B!=A+1:
    B=B-1
  else:
    B=B+1
  turn+=1
if A==1:
  print('Borys')
else:
  print('Alice')
    


### FIXED CODE ###

N,A,B=map(int, input().split())
turn=0
while A!=1 and B!=N or turn==0:
  if A!=B-1:
    A+=1
  else:
      A=A-1
  if A<1:
      A=1
  if B!=A+1:
    B=B-1
  else:
    B=B+1
  if B>N:
      B=N
  turn+=1
if A==1:
  print('Borys')
else:
  print('Alice')
### BUGGY CODE ###

f = 0
def ts(E):
    L = []
    n = len(E)
    done = [0] * n
    checking = [0] * n
    def visit(j):
        global f
        checking[j] = 1
        if done[j] == 0:
            done[j] = 1
            for k in E[j]:
                if f: return 1
                if checking[k]:
                    f = 1
                    return 1
                visit(k)
                D[j] = max(D[j], D[k] + 1)
            L.append(j)
        checking[j] = 0
        return f
    for i in range(n):
        if visit(i):
            return []
    return L[::-1]

def ca(i, j):
    return max(i, j) * (max(i, j)-1) // 2 + min(i, j)

N = int(input())
M = N * (N-1) // 2
X = [[] for i in range(M)]
for i in range(N):
    A = [int(a)-1 for a in input().split()]
    for j in range(N-2):
        X[ca(i, A[j])].append(ca(i, A[j+1]))
D = [0] * M
L = ts(X)
print(max(D) + 1 if L else -1)

### FIXED CODE ###

N = int(input())
X = [[int(a)-1 for a in input().split()] for _ in range(N)]
Y = [0] * N
Z = [-1] * N

L = [a for a in range(N)]
f = 1
d = 0
c = 0
while f:
    d += 1
    f = 0
    NL = []
    for l in L:
        a, aa = Y[l], Z[l]
        if a >= N - 1: continue
        ll = X[l][a]
        b, bb = Y[ll], Z[ll]
        if b >= N - 1: continue
        lll = X[ll][b]
        if lll == l and aa < d and bb < d:
            f = 1
            c += 1
            Y[l] += 1
            Z[l] = d
            if Y[l] < N - 1: NL.append(l)
            Y[ll] += 1
            Z[ll] = d
            if Y[ll] < N - 1: NL.append(ll)
    if c == N*(N-1)//2:
        print(d)
        break
    L = NL
else:
    print(-1)