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

primes = [0, 0] + [1]*9999999
for i in range(2, 3163):
    for j in range(i*i, 10000001, i):
        primes[j] = 0

while True:
    n = int(input())
    if n == 0:
        break
    for i in range(5, n+1)[::-1]:
        if primes[i] and primes[i-2] and primes[i-6] and primes[i-8]:
            print(i)
            break

### FIXED CODE ###

import bisect


primes = [0, 0] + [1] * 9999999
for i in range(2, 3163):
    if primes[i]:
        for j in range(i*i, 10000001, i):
            primes[j] = 0

values = [i for i, v in enumerate(primes) if v]
while True:
    n = int(input())
    if n == 0:
        break
    index = bisect.bisect(values, n)
    for i in range(2, index)[::-1]:
        if all(primes[values[i]-j] for j in [0, 2, 6, 8]):
            print(values[i])
            break
### BUGGY CODE ###

import bisect

N, M, Q = map(int, input().split())
trains = [list(map(int, input().split())) for i in range(M)]
queries = [list(map(int, input().split())) for i in range(Q)]

A  =[[0] * N for _ in range(N)] #A[i][j] = (i + 1) -> (j+1)なる列車の本数
for train in trains:
    li, ri = train
    A[li - 1][ri - 1] += 1
dp = [[0] * N for __ in range(N)]

def ans(left, right):
    if dp[left][right] > 0:
        return dp[left][right]
    elif left > right:
        return 0
    elif left == right:
        dp[left][right] = A[left][right]
        return A[left][right]
    else:
        x = ans(left, right-1) + ans(left + 1, right) + A[left][right] - ans(left + 1, right - 1)
        dp[left][right] = x
        return x

for q in range(Q):
    pi, qi = queries[q]
    print(ans(pi - 1, qi - 1))


### FIXED CODE ###

N, M, Q = map(int, input().split())
trains = [list(map(int, input().split())) for i in range(M)]
queries = [list(map(int, input().split())) for i in range(Q)]

A  =[[0] * N for _ in range(N)] #A[i][j] = (i + 1) -> (j+1)なる列車の本数
for train in trains:
    li, ri = train
    A[li - 1][ri - 1] += 1

dp = [[0] * N for __ in range(N)]
for i in range(N - 1, -1, -1):
    for j in range(i, N):
        if i == j:
            dp[i][j] = A[i][j]
        else:
            dp[i][j] = dp[i][j - 1] + dp[i + 1][j] + A[i][j] - dp[i + 1][j - 1]
for q in range(Q):
    pi, qi = queries[q]
    print(dp[pi - 1][ qi - 1])
### BUGGY CODE ###

H,W,D = list(map(int, input().split()))
A = []
for i in range(H):
    A.append(list(map(int, input().split())))
Q = int(input())
L = [0 for _ in range(Q)]
R = [0 for _ in range(Q)]
for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))


masu = [[0,0] for _ in range(H*W)]
for i in range(H):
    for j in range(W):
        masu[A[i][j]-1] = [i, j]

MP = [0 for _ in range(Q)]
for k in range(Q):
    K = L[k]
    i, j = masu[K-1]
    while A[i][j] != R[k]:
        K = K + D
        x, y = masu[K-1]
        MP[k] += abs(x-i) + abs(y-j)
        i, j = x, y

for i in range(Q):
    print(MP[i])


### FIXED CODE ###

H,W,D = list(map(int, input().split()))
A = []
for i in range(H):
    A.append(list(map(int, input().split())))

Q = int(input())
L = [0 for _ in range(Q)]
R = [0 for _ in range(Q)]
for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

masu = [[0,0] for _ in range(H*W)]
for i in range(H):
    for j in range(W):
        masu[A[i][j]-1] = [i, j]

MP = [0 for _ in range(H*W)]
for i in range(H*W):
    if i < D:
        MP[i] = 0
    else:
        MP[i] = MP[i-D] + abs(masu[i][0]-masu[i-D][0]) + abs(masu[i][1]-masu[i-D][1])

for i in range(Q):
    print(MP[R[i]-1] - MP[L[i]-1])
### BUGGY CODE ###

import sys
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    for i in range(10 ** 6, 0, -1):
        p0 = p
        count = 0
        while p0 % i == 0:
            p0 //= i
            count += 1
            if count == n:
                print(i)
                sys.exit()

### FIXED CODE ###

n,p = map(int,input().split())
dum = round(p**(1/n))
for i in range(dum,-1,-1):
    if p%(i**n) == 0:
        print(i)
        break
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from operator import xor
from functools import reduce

rS = input()
S = int(rS, 2)

L = len(rS)
k = len(rS)

dp = set([0])
while True:
    A = [sum([2**i for i in range(I, I+k)]) for I in range(L-k+1)]
    B = set([reduce(xor, A_) for i in range(0, L-k+1) for A_ in product(A, repeat=i+1)])
    dp.update([d^b for d, b in product(dp, B)])
    if S in dp:
        break
    else:
        #print(dp)
        k -= 1
print(k)

### FIXED CODE ###

# -*- coding: utf-8 -*-
S = input()
n = len(S)
L = list(map(int, list(S)))
D = []
res = 0
for k in range(n-1):
    if L[k] != L[k+1]:
        D.append(max(k+1, n-k-1))

if len(D):
    print(min(D))
else:
    print(n)
### BUGGY CODE ###

N,M = map(int,input().split())
gcd = 1
gcd_tmp = 0
while gcd * N <= M:
 tmp = M - gcd
 if tmp % gcd == 0:
  gcd_tmp = gcd
 gcd = gcd + 1
print(gcd_tmp)

### FIXED CODE ###

def calc():
 N,M = map(int,input().split())
 for gcd in range(M // N,0,-1):
  if M % gcd == 0:
   break
 return(gcd)
print(calc())
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
C = defaultdict(int)
for i in range(N):
  D = int(input())
  C[D] = i + 1
E = []
H = [1] * (N + 1)
DD = sorted([[k, v] for k, v in C.items()], reverse=True)
Adj = [[] for i in range(N)]
for D, n in DD[:-1]:
  try:
    p = C[D - N + 2 * H[n]]
    if n == p:
      raise Error
    E.append([n, p])
    Adj[n - 1].append(p - 1)
    Adj[p - 1].append(n - 1)
    H[p] += H[n]
  except:
    print(-1)
    break
else:
  dist = [N] * N
  dist[DD[-1][1] - 1] = 0
  Q = [DD[-1][1] - 1]
  while Q:
    s = Q[0]
    Q = Q[1:]
    for adj in Adj[s]:
      if dist[s] + 1 < dist[adj]:
        dist[adj] = dist[s] + 1
        Q.append(adj)
  if sum(dist) == DD[-1][0]:
    for e in E:
      print(e[0], e[1])
  else:
    print(-1)

### FIXED CODE ###

from collections import defaultdict
N = int(input())
C = defaultdict(int)
for i in range(N):
  D = int(input())
  C[D] = i + 1
E = []
H = [1] * (N + 1)
DD = sorted([[k, v] for k, v in C.items()], reverse=True)
Adj = [[] for i in range(N)]
for D, n in DD[:-1]:
  try:
    p = C[D - N + 2 * H[n]]
    if n == p:
      raise Error
    E.append([n, p])
    Adj[n - 1].append(p - 1)
    Adj[p - 1].append(n - 1)
    H[p] += H[n]
  except:
    print(-1)
    break
else:
  dist = [N] * N
  dist[DD[-1][1] - 1] = 0
  Q = [DD[-1][1] - 1] + [N] * N
  tail = 1
  for i in range(N):
    s = Q[i]
    if s == N:
      print(-1)
      break
    for adj in Adj[s]:
      if dist[adj] == N:
        dist[adj] = dist[s] + 1
        Q[tail] = adj
        tail += 1
  else:
    if sum(dist) == DD[-1][0]:
      for e in E:
        print(e[0], e[1])
    else:
      print(-1)
### BUGGY CODE ###

import collections
n = int(input())
s = [input() for i in range(n)]
#print(s)
c = collections.Counter(s)
#print(c.most_common())
a = []
a.append(c.most_common()[0][0])
for i in range(1,len(c.most_common())):
    if c.most_common()[0][1]==c.most_common()[i][1]:
        a.append(c.most_common()[i][0])
print(*sorted(a))

### FIXED CODE ###

import collections
n = int(input())
s = [input() for i in range(n)]
#print(s)
c = collections.Counter(s)
#print(c.most_common())
a = []
b = (c.most_common())
#print(b)
a.append(b[0][0])
for i in range(1,len(b)):
    if b[0][1] == b[i][1]:
        a.append(b[i][0])
print(*sorted(a))
### BUGGY CODE ###

n, m = map(int, input().split())
X = [int(x) for x in input().split()]
Y = [int(x) for x in input().split()]
p = 10 ** 9 + 7
ans = 0
for i in range(n - 1):
  for j in range(m - 1):
    S = (X[i + 1] - X[i]) * (Y[j + 1] - Y[j]) * (n - i - 1) * (i + 1) * (m - j - 1) * (j + 1) % p
    ans += S
print(ans % p)

### FIXED CODE ###

n, m = map(int, input().split())
p = 10 ** 9 + 7
X = [int(x) for x in input().split()]
Y = [int(x) for x in input().split()]
XX = [(X[i + 1] - X[i]) * (n - i - 1) * (i + 1) % p for i in range(n - 1)]
YY = [(Y[j + 1] - Y[j]) * (m - j - 1) * (j + 1) % p for j in range(m - 1)]
print(sum(XX) * sum(YY) % p)
### BUGGY CODE ###

import math

def is_prime(n):
    nmax = int(math.sqrt(n)) + 1
    for i in range(2, nmax):
        if(n%i)==0:
            return False
    return True

def pf(n):
    sn = int(math.sqrt(n)) + 1
    ps = []
    for i in range(1, sn):
        if (n%i)==0:
            ps.append(i)
            ps.append(int(n/i))
    del ps[0]
    return ps        

n = int(input())
ps = []
num = pf(n)
for i in num:
    if is_prime(i):
        ps.append(i)
        
zs = []        
for p in ps:
    z = p
    while(z<=n):
        zs.append(z)
        z *= p
zs.sort()
cnt = 0
for z in zs:
    if(n>1):
        if(n%z==0):
            n /= z
            cnt += 1
print(cnt)

### FIXED CODE ###

import math

def is_prime(n):
    if n==1:
        return False
    nmax = int(math.sqrt(n)) + 1
    for i in range(2, nmax):
        if(n%i)==0:
            return False
    return True

def pf(n):
    sn = int(math.sqrt(n)) + 1
    ps = []
    for i in range(1, sn):
        if (n%i)==0:
            ps.append(i)
            ps.append(int(n/i))
    del ps[0]
    return ps        

n = int(input())
ps = []
num = pf(n)
for i in num:
    if is_prime(i):
        ps.append(i)
        
zs = []        
for p in ps:
    z = p
    while(z<=n):
        zs.append(z)
        z *= p
zs.sort()

cnt = 0
for z in zs:
    if(n>1):
        if(n%z==0):
            n /= z
            cnt += 1
print(cnt)
### BUGGY CODE ###

import numpy as np
H,W,M = map(int,input().split())
#h = np.empty(M,dtype=np.int)
#w = np.empty(M,dtype=np.int)
bomb = set()
hh = np.zeros(H+1,dtype=np.int32)
ww = np.zeros(W+1,dtype=np.int32)

for i in range(M):
    h,w = map(int,input().split())
    bomb.add((h,w))
    hh[h] += 1
    ww[w] += 1

#print(bomb)
h_max = np.max(hh)
w_max = np.max(ww)

b = 1
for i in range(1,H+1):
  for j in range(1,W+1):
    if hh[i] == h_max and ww[j] == w_max:
      if not (i,j) in bomb:
        b = 0
      #else:
        #print("[{}, {}] exists".format(i,j))
#print("hmax:{} wmax:{}".format(h_max_id, w_max_id))
#print("hmax:{} wmax:{}".format(hh[h_max_id], ww[w_max_id]))
print(h_max + w_max - b)


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline

    h,w,m = map(int, input().split())
    h_count = [0 for _ in range(h)]
    w_count = [0 for _ in range(w)]
    pairs = set()

    for i in range (m):
        hi, wi = map(int, input().split())
        hi -= 1
        wi -= 1

        h_count[hi] += 1
        w_count[wi] += 1

        pairs.add((hi,wi))

    h_max = max(h_count)
    w_max = max(w_count)
    hk = list()
    wk = list()

    for index , hj in enumerate(h_count):
        if hj == h_max:
            hk.append(index)
    
    for index, wj in enumerate(w_count):
        if wj == w_max:
            wk.append(index)

    ans = h_max + w_max

    for _h in hk:
        for _w in wk:
            hw = (_h, _w)

            if hw in pairs:
                continue

            print(ans)
            exit()
    print(ans -1)

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

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
  S = input()
  N = int(input())

  ans = ""
  for i in range(N):
    list = input().split()
    if list[0] == '1':
      S = S[::-1]
      continue
    if list[1] == '1':
      S = list[2] + S
      continue
    S += list[2]
  print(S)

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

from collections import deque

def main():
  S = deque(input())
  N = int(input())

  d = True
  for i in range(N):
    list = input().split()
    if list[0] == '1':
      d = not d
      continue
    if list[1] == '1':
      S.appendleft(list[2]) if d else S.append(list[2])
      continue
    S.append(list[2]) if d else S.appendleft(list[2])
  return ''.join(S) if d else ''.join(S)[::-1]

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

def main():
    N = int(input())
    a_list = list(map(int, input().split()))

    sum = 0
    for i in range(N-1):
        for j in range(i+1, N):
           sum += a_list[i] ^ a_list[j]

    print(sum % (10**9+7))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    t = [0]*60

    for a in a_list:
        for count, i in enumerate(reversed(format(a, "b"))):
            if i == "1":
                t[count] += 1

    sum = 0
    for i, count in enumerate(t):
        sum += 2 ** i * count * (N - count)
    print(sum % mod)


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

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# K, N = [int(x) for x in input().split()]

N, M = [int(x) for x in input().split()]
city = []
for n in range(M):
    P, Y = [int(x) for x in input().split()]
    city.append([Y, P, n, 1])

city = np.array(city)
city2 = []

for n in range(N):
    s = np.sort(city[city[:, 1] == n+1][:, 0])
    for ss, nn in zip(s, range(1, len(s)+1)):
        l = list(city[city[:, 0] == ss][0, 0:3])
        l.append(nn)
        city2.append(l)
city2 = np.array(city2)

city2 = city2[np.argsort(city2[:, 2])]

for c in city2:
    print(str(c[1]).zfill(6) + str(c[3]).zfill(6))



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# K, N = [int(x) for x in input().split()]

N, M = [int(x) for x in input().split()]
city = []

for n in range(M):
    P, Y = [int(x) for x in input().split()]
    city.append([n, P, Y])
city = np.array(city)
city = city[np.argsort(city[:, 2])]
counts = np.array([1]*N)

city2 = []

for n in range(M):
    city2.append([city[n, 0], city[n, 1], city[n, 2], counts[city[n, 1]-1]])
    counts[city[n, 1]-1] += 1

city2 = np.array(city2)
city2 = city2[np.argsort(city2[:, 0])]
for c in city2:
    print(str(c[1]).zfill(6) + str(c[3]).zfill(6))
### BUGGY CODE ###

n = int(input())
s = input()
r = []
g = []
b = []
res = 0
for i in range(n):
  if s[i] == 'R':
    r.append(i)
  elif s[i] == 'G':
    g.append(i)
  else:
    b.append(i)
if max(len(r),len(g),len(b)) == len(b):
  for i in g:
    for j in r:
      res += len(b) - b.count((i + j) / 2) - b.count( 2 * i - j) - b.count(2 * j - i)
else:
  for i in b:
    for j in r:
      res += len(g) - g.count((i + j) / 2) - g.count( 2 * i - j) - g.count(2 * j - i)
print(res)


### FIXED CODE ###

n=int(input())
s=input()
R=[]
G={}
B=[]
for i in range(n):
  if s[i]=='R':
    R.append(i+1)
  elif s[i]=='G':
    G[i+1]=G.get(i+1,0)+1
  else:
    B.append(i+1)
res=len(R)*len(G)*len(B)
for i in R:
  for j in B:
    if ((i+j)%2==0 and G.get((i+j)//2,0)==1):
      res-=1
    if G.get(2*max(i,j)-min(i,j),0)==1:
      res-=1
    if G.get(2*min(i,j)-max(i,j),0)==1:
      res-=1
print(res)
### BUGGY CODE ###

r,g,b,n = map(int,input().split())

res=0
tmp=n
tmp1=0
t1 = [r,g,b]
t2 = sorted(t1, reverse=True)
#print(t2)

for i in range(n//t2[0]+1):
	tmp -= i*t2[0]
	tmp1 = tmp
	for j in range(n//t2[1]+1):
		tmp1 -= j*t2[1]
		if tmp1 >= 0 and tmp1%t2[2]==0:
			res+=1
			#print(i, j, int(tmp1/t2[2]))
		tmp1 = tmp
	tmp=n

print(res)

### FIXED CODE ###

r,g,b,n = map(int,input().split())

res=0
tmp=n
tmp1=0
re=n//r+1
ge=n//g+1

for i in range(re):
	tmp = tmp - i*r
	tmp1 = tmp
	for j in range(ge):
		tmp1 = tmp - j*g
		if tmp1 >= 0 and tmp1%b==0:
			res = res + 1
			#print(i, j, int(tmp1/t2[2]))
		tmp1 = tmp
	tmp=n

print(res)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N,M = map(int,input().split())
L = []
for i in range(N):
  tmp = list(map(int,input().split()))
  L.append(tmp[1:])

dicL = {}
for i in range(N):
  for l in L[i]:
    if l not in dicL:
      dicL[l] = [i]
    else:
      dicL[l].append(i)
#print(dicL)
E = [[] for _ in range(N)]
for k,v in dicL.items():
  if len(v) > 1:
    for i in range(len(v)-1):
      for j in range(i+1,len(v)):
        E[v[i]].append(v[j])
        E[v[j]].append(v[i])
#for i in range(N):
#  E[i] = set(E[i])
#print(E)
Visited = [0 for _ in range(N)]
def dfs(v):
  Visited[v] = 1
  for u in E[v]:
    if Visited[u] == 0:
      dfs(u)
dfs(0)
print('YES' if sum(Visited) == N else 'NO')
    

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N,M = map(int,input().split())
L = []
for i in range(N):
  tmp = list(map(int,input().split()))
  L.append(tmp[1:])
#print(L)

# 人(0~N-1)と言語(N~M-1)の間で二部グラフを作る
E = [set() for _ in range(N+M)]
for i in range(N):
  for l in L[i]:
    E[i].add(l+N-1)
    E[l+N-1].add(i)
#print(E)

# 人のノードすべてに到達可能であればYES
Visited = [0 for _ in range(N+M)]
def dfs(v):
  Visited[v] = 1
  for u in E[v]:
    if Visited[u] == 0:
      dfs(u)
dfs(0)
print('YES' if sum(Visited[:N]) == N else 'NO')
### BUGGY CODE ###

L,M=map(int,input().split())
a=[0]*L
for i in range(M):
    b,c=map(int,input().split())
    for j in range(b-1,c):
        a[j]+=1
print(a.count(M))

### FIXED CODE ###

L,M=map(int,input().split())
a=[0]*L
x=[]
y=[]
for i in range(M):
    b,c=map(int,input().split())
    x.append(b)
    y.append(c)
if max(x)<=min(y):
    print(-max(x)+min(y)+1)
else:
    print(0)
### BUGGY CODE ###

m=10**9+7
input()
i=s=r=0
f=1
a=input().split()
for _ in a:
 s+=pow(i+1,m-2,m)
 r+=int(a[i])*~-s+int(a[~i])*s
 i+=1
 f*=i
print(r*f%m)

### FIXED CODE ###

m=10**9+7
input()
i=s=r=0
f=1
a=input().split()
for _ in a:
 s+=pow(i+1,m-2,m);r+=int(a[i])*~-s+int(a[~i])*s;i+=1;f=f*i%m
print(r*f%m)
### BUGGY CODE ###

import math
n=int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def check(x,y):
    if float.is_integer(math.sqrt(x)) and float.is_integer(math.sqrt(y)):
        return True

x,y=0,0
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        x=i
        y=n//i
print("0 0 0 "+str(x)+" "+str(y)+" 0")

### FIXED CODE ###

import math
n=int(input())
x1,y1=0,0
x2,y2=10**9,1
y3 = n//x2 +1
if y3>x2:
    y3=x2
x3 = y3*x2 - n


output=[x1,y1,x2,y2,x3,y3]
output=list(map(str,output))
    
print(" ".join(output))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
a = tuple(sorted(a))
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    chk = a[i]+a[j]
    for k in range(j+1,n):
      if a[k] >= chk:
        ans += (k-j-1)
        break
      if k == n-1:
        ans += (n-j-1)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
n = int(input())
a = [int(i) for i in input().split()]
a = tuple(sorted(a))
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    chk = a[i]+a[j]
    ind = bisect.bisect_left(a,chk)
    ans += (ind-j-1)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline


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

JOBS = []
for _ in range(n):
    a, b = map(int, input().split())
    JOBS.append((b, a))
JOBS.sort(reverse = True)

REWARDS = [0] * m
count = 0
for job in JOBS:
    i = m - job[1]
    while i >= 0:
        if REWARDS[i] == 0:
            REWARDS[i] = job[0]
            count += 1
            break
        else:
            i -= 1
    if count == m:
        break

answer = sum(REWARDS)
print(answer)


### FIXED CODE ###

import sys
input = sys.stdin.readline
from heapq import*


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

JOBS = {i:[] for i in range(1, m + 1)}
for _ in range(n):
    a, b = map(int, input().split())
    if a <= m:
        JOBS[a].append(b)

answer = 0
REWARDS = []
heapify(REWARDS)
for i in range(1, m + 1):
    for reward in JOBS[i]:
        heappush(REWARDS, -reward)
    if len(REWARDS) > 0:
        reward = -heappop(REWARDS)
        answer += reward

print(answer)
### BUGGY CODE ###

import bisect
N = int(input())
A = [0]
A += list(map(int, input().split()))
cnt = 0
L = [- 10 ** 6]
R = [- 10 ** 6]

for i in range(1, N + 1):
    L.append(i + A[i])
    R.append(i - A[i])
L.sort()
for j in range(1, N + 1):
    x = bisect.bisect_left(L, R[j])
    while R[j] == L[x]:
        cnt += 1
        x += 1
print(cnt)

### FIXED CODE ###

import collections
N = int(input())
A = [0]
A += list(map(int, input().split()))
cnt = 0
L = [- 10 ** 6]
R = [- 10 ** 6]

for i in range(1, N + 1):
    L.append(i + A[i])
    R.append(i - A[i])
c = collections.Counter(L)

for j in range(1, N + 1):
    cnt += c.get(R[j], 0)
print(cnt)
### BUGGY CODE ###

from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)%mod
        ans %= mod

    print(ans % mod)
main()

### FIXED CODE ###

from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(500000)
N=int(input())
A=[int(input())-1 for _ in range(N)]
result=[]
app=result.append
def next(k):
	newlight=A[k]
	if k==1:
		return(1)
	elif k in result:
		return(0)
	else:
		app(k)
		return(next(newlight))
if not next(0):
	print(-1)
else:print(len(result))

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
N=int(input())
A=[int(input())-1 for _ in range(N)]
result=[False]*N
def next(k):
	newlight=A[k]
	if k==1:
		return(1)
	elif result[k]:
		return(0)
	else:
		result[k]=True
		return(next(newlight))
if not next(0):
	print(-1)
else:print(sum(result))
### BUGGY CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[17]:


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


# In[18]:


ans = 0
for i,x in enumerate(H):
    tmp = 0
    height = x
    for j in range(i+1,N):
        if height >= H[j]:
            tmp += 1
            height = H[j]
        else:
            break
    ans = max(ans, tmp)
print(ans)


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[25]:


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


# In[26]:


ans = 0
x = 0
while x < N-1:
    tmp = 0
    height = H[x]
    for y in range(x+1,N):
        if height >= H[y]:
            tmp += 1
            height = H[y]
        else:
            break
    ans = max(ans, tmp)
    x = y
print(ans)


# In[ ]:
### BUGGY CODE ###

n,k=list(map(int, input().split()))
h=list(map(int, input().split()))
c=[0]
for i in range(n-1):
    if i+1<k:
        d = [c[i-j]+abs(h[i-j]-h[i+1]) for j in range(i+1)]
    else:
        d = [c[i-j]+abs(h[i-j]-h[i+1]) for j in range(k)]
    c.append(min(d))
print(c[-1])

### FIXED CODE ###

N,K=list(map(int, input().split()))
H=list(map(int, input().split()))
"""c=[0]
for i in range(N-1):
    if i+1<K:
        d = [c[i-j]+abs(H[i-j]-H[i+1]) for j in range(i+1)]
    else:
        d = [c[i-j]+abs(H[i-j]-H[i+1]) for j in range(K)]
    c.appeNd(miN(d))
#print(c[-1])"""
H = [H[0]] * K + H
#print(H)
INF = 10**18
dp = [INF] *(K+N)
#print(dp)
dp[0]=0
#print(dp)
for i in range(K, N+K):
    h = H[i]
    costs = [x+abs(y-h) for x, y in zip(dp[i - K:i], H[i - K:i])]
    dp[i] = min(costs)
#print(dp)
print(dp[-1])
### BUGGY CODE ###

from collections import Counter
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    s_c = Counter(s)
    keys = [k for k, v in s_c.items() if v == max(s_c.values())]
    keys_s = sorted(keys)
    print(*keys_s, sep='\n')

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    s_c = Counter(s)
    s_c_max = s_c.most_common()[0][1]
    keys =[k for k, v in s_c.items() if v == s_c_max]
    keys_s = sorted(keys)
    print(*keys_s, sep='\n')

if __name__ == '__main__':
    main()