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

n = int(input())
a = list(map(int, input().split()))
a = [A for A in a if a != 0]
from itertools import combinations

MOD = 10**9 + 7
ans = 0
for i,j in combinations(a, 2):
    ans = ans + (i*j)%MOD

print(ans%MOD)

### FIXED CODE ###

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

from itertools import accumulate
cumsum = list(accumulate(a[::-1]))[::-1]

MOD = 10**9+7
ans = 0
for i,A in enumerate(a[:-1]):
    ans += A * cumsum[i+1]
    ans = ans % MOD
print(ans)
### BUGGY CODE ###

def main():
    N, P = (int(i) for i in input().split())
    S = input()

    ans = 0
    if P == 5 or P == 2:
        for i in range(1):
            for j in range(1, N-i+1):
                num = int(S[i:i+j])
                if num % P == 0:
                    # print("!", end=" ")
                    ans += len(S[i:i+j])
                # print(num)
    else:
        from itertools import accumulate
        S = S[::-1]
        acc = [(int(s)*10**i) % P for i, s in enumerate(S)]
        acc = list(accumulate([0] + acc))
        acc = [a % P for a in acc]
        from collections import Counter
        c = Counter(acc)
        # print(acc, c)
        for v in c.values():
            ans += v*(v-1)//2
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from collections import Counter
    N, P = (int(i) for i in input().split())
    S = [int(s) for s in input()]

    ans = 0
    if P == 5 or P == 2:
        for i, s in enumerate(S, start=1):
            # j文字取る
            if s % P == 0:
                ans += i
    else:
        acc = [0]*(N+1)
        d = 1
        for i, s in enumerate(S[::-1], start=1):
            # print(i, s)
            acc[i] = (s * d + acc[i-1]) % P
            d *= 10
            d %= P
        c = Counter(acc)
        # print(acc, c)
        ans = sum(v*(v-1)//2 for v in c.values())
    print(ans)


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

n,m = map(int, input().split())
PY = [[] for i in range(m)]
for i in range(m):
  PY[i] = list(map(int, input().split()))
  PY[i].append(i)
  
PY.sort(key = lambda x:x[1])
PY.sort(key = lambda x:x[0])

l = [0]*(n)
for i in range(m):
  l[PY[i][0]-1]+=1

for i in range(n):
  j = 0
  while j < l[i]:
    list(filter(lambda x:x[0]==i+1,PY))[j].append(j+1)
    j += 1
  
PY.sort(key = lambda x:x[2])
for i in range(m):
  print('{:0=6}'.format(PY[i][0])+'{:0=6}'.format(PY[i][3]))

### FIXED CODE ###

n,m = map(int, input().split())
PY = [[] for i in range(m)]
for i in range(m):
  PY[i] = list(map(int, input().split()))
  PY[i].append(i)
  
PY.sort(key = lambda x:x[1])

l = [0]*(n)
for i in range(m):
  l[PY[i][0]-1]+=1
  PY[i].append(l[PY[i][0]-1])

  
PY.sort(key = lambda x:x[2])
for i in range(m):
  print('{:0=6}'.format(PY[i][0])+'{:0=6}'.format(PY[i][3]))
### BUGGY CODE ###

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    num = int(input())
    s = list(input())

    for i in range(1, num)[::-1]:
        if s[i] == s[i - 1]:
            s.pop(i)

    print(len(s))






if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    num = int(input())
    s = list(input())
    ans = 0
    for i in range(1, num)[::-1]:
        if s[i] == s[i - 1]:
            ans += 1

    print(len(s) - ans)






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

# coding: utf-8

def f(n, k, h):
    dp = [float('inf') for _ in range(n)]
    dp[0] = 0
    for i in range(1, n):
        js = max(i - k, 0)
        for j in range(js, i):
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))
    return(dp[i])

n, k = map(int, input().rstrip().split())    # 2 <= n <= 10^5, 1 <= k <= 100
h = list(map(int, input().rstrip().split()))

print(f(n, k, h))


### FIXED CODE ###

# coding: utf-8

def f(n, k, h):
    dp = [0 for _ in range(n)]
    for i in range(1, n):
        js = max(i - k, 0)
        dp[i] = min(dp[j] + abs(h[i] - h[j]) \
            for j in range(js, i))
        # print(dp)
    return(dp[i])

n, k = map(int, input().rstrip().split())    # 2 <= n <= 10^5, 1 <= k <= 100
h = list(map(int, input().rstrip().split()))

print(f(n, k, h))
### BUGGY CODE ###

N = int(input())

height = input()
height = height.split()
height = [int(s) for s in height]

count = 0

for i in range(N):
  for j in range(i+1, N):
    if abs(i-j) == abs(height[i] + height[j]):
      count += 1

print(count)

### FIXED CODE ###

import collections

N = int(input())

height = input()
height = height.split()
height = [int(s) for s in height]

count = 0


d = dict(collections.Counter([i + height[i] for i in range(N)]))
ans = sum([d.get(i - height[i], 0) for i in range(N)])
print(ans)
### BUGGY CODE ###

from itertools import combinations

N = int(input())
L = [int(x) for x in input().split()]

count = 0
for a, b, c in combinations(L, 3):
    if a < b + c and b < c + a and c < a + b:
        count += 1

print(count)

### FIXED CODE ###

from bisect import bisect_left

N = int(input())
L = [int(x) for x in input().split()]

L = sorted(L)

ans = 0

for mid in range(N - 1, -1, -1):
    for low in range(mid - 1, -1, -1):
        itr = bisect_left(L, L[low] + L[mid])
        ng = len(L) - itr
        ans += (N - 1 - mid) - ng

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

import sys
import queue

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def gg(nn, x, y, n, is_sit):
	q = queue.Queue()
	q.put(1000*x+y)
	cl = set()
	cl.add(x*1000+y)
	while not q.empty():
		v = q.get()
		x,y = v//1000, v %1000
		nn[x][y] -= 1
		k = nn[x][y]
		for dx,dy in ([-1,0], [0,-1], [1,0], [0,1]):
			if x+dx < 0 or x +dx >= n or y + dy < 0 or y + dy >= n:
				continue
			if nn[x+dx][y + dy] <= k + is_sit[x+dx][y+dy]:
				continue
			if (x+dx)*1000+(y+dy) in cl:
				continue
			q.put((x+dx)*1000+ (y+dy))
			cl.add((x+dx)*1000 + (y+dy))
		#print('yyyyyy')
		#for l in nn:
		#	print(l)

def main():
	n = int(input())
	nn = [[(n+1)//2] * n for _ in range(n)]
	is_sit = [[1] * n for _ in range(n)]
	for i in range(n):
		for j in range(n):
			nn[i][j] = min(i+1,j+1,n-i,n-j)
	#for l in nn:
	#	print(l)
	
	#b , c = tin()
	pl = lin()
	ans = 0
	for p in pl:
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]-1
		is_sit[x][y] = 0
		gg(nn, x, y, n, is_sit)
		
	print(ans)
	#s = input()
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

#+++++

def main():
	n = int(input())
	nn = [[min(i,j,n-i-1,n-j-1) for j in range(n)] for i in range(n)]
	is_sit = [[True] * n for _ in range(n)]
	cc = [[0]*n for _ in range(n)]
	
	#b , c = tin()
	pl = list(map(int, input().split()))
	ans = 0
	for p in pl:
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]
		is_sit[x][y] = False
		q = [(x, y, nn[x][y])]
		while q:
			(x, y, v) = q.pop()
			if x >= 0 and nn[x-1][y]>v:
				nn[x-1][y] = v
				q.append((x-1, y, v+is_sit[x-1][y]))
			if x < n-1 and nn[x+1][y]>v:
				nn[x+1][y] = v
				q.append((x+1, y, v+is_sit[x+1][y]))		
			if y >= 0 and nn[x][y-1]>v:
				nn[x][y-1] = v
				q.append((x, y-1, v+is_sit[x][y-1]))
			if y < n-1 and nn[x][y+1]>v:
				nn[x][y+1] = v
				q.append((x, y+1, v+is_sit[x][y+1]))	
		
	print(ans)
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines

s = readline().rstrip()
q = readline()
queries = readlines()
tot_1 = 0
for i in queries:
    if i[0] == '1':
        tot_1 += 1
        continue
    if (tot_1 + int(i[2])) % 2 == 0:
        s = s + i[4]
    else:
        s = i[4] + s
if tot_1 % 2 == 1:
    s = s[::-1]
print(s)


### FIXED CODE ###

import sys
from collections import deque

readline = sys.stdin.readline
readlines = sys.stdin.readlines

s = readline().rstrip()
q = readline()
queries = readlines()
s = deque(s)
tot_1 = 0
for i in queries:
    if i[0] == '1':
        tot_1 += 1
        continue
    c = i[4]
    if (tot_1 + int(i[2])) % 2 == 0:
        s.append(c)
    else:
        s.appendleft(c)
ans = "".join(s) if tot_1 % 2 == 0 else "".join(reversed(s))
print(ans)
### BUGGY CODE ###

from collections import Counter 

n = int(input())
a = list(map(int, input().split()))
co = Counter(a)
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    if b in co.keys():
        co[c] += co[b]
        co[b] = 0
    ans = 0
    for i in co.items():
        ans += i[0] * i[1]
    print(ans)

### FIXED CODE ###

from collections import Counter 

n = int(input())
a = list(map(int, input().split()))
co = Counter(a)
q = int(input())
ans = 0
for i in co.items():
    ans += i[0] * i[1]
for _ in range(q):
    b, c = map(int, input().split())
    if b in co.keys():
        ans -= b * co[b]
        co[c] += co[b]
        ans += c * co[b]
        co[b] = 0
    print(ans)
### BUGGY CODE ###

#縦k、横kのマスに移動させて考える
n, k = map(int, input().split())
x = []
y = []
mx = []
my = []
for _ in range(n):
    xx, yy, c = input().split()
    xx = int(xx)
    yy = int(yy)
    if c == 'W':
        xx += k
    xx %= 2 * k
    yy %= 2 * k
    if xx >= k:
        if yy >= k:
            x.append(xx - k)
            y.append(yy - k)
        else:
            mx.append(xx - k)
            my.append(yy)
    else:
        if yy >= k:
            mx.append(xx)
            my.append(yy - k)
        else:
            x.append(xx)
            y.append(yy)

graph = [[0 for _ in range(k)] for __ in range(k)]

#累積和
#lx + lmx = n
lx = len(x)
for i in range(lx):
    for j in range(x[i], k):
        graph[j][y[i]] += 1
    for j in range(x[i]):
        graph[j][0] += 1
        graph[j][y[i]] -= 1

lmx = len(mx)
for i in range(lmx):
    for j in range(mx[i], k):
        graph[j][my[i]] -= 1
    for j in range(mx[i]):
        graph[j][0] -= 1
        graph[j][my[i]] += 1

for i in range(k):
    for j in range(k-1):
        graph[i][j+1] += graph[i][j]

#最大値、最小値を取得
big = max([max(i) for i in graph]) + lmx
small = min([min(i) for i in graph]) - lx

if big + small >= 0:
    print(big)
else:
    print(-small)

### FIXED CODE ###

import sys

#縦k、横kのマスに移動させて考える
n, k = map(int, sys.stdin.readline().strip().split())
x = []
y = []
mx = []
my = []
for _ in range(n):
    xx, yy, c = sys.stdin.readline().strip().split()
    xx = int(xx)
    yy = int(yy)
    if c == 'W':
        xx += k
    xx %= 2 * k
    yy %= 2 * k
    if xx >= k:
        if yy >= k:
            x.append(xx - k)
            y.append(yy - k)
        else:
            mx.append(xx - k)
            my.append(yy)
    else:
        if yy >= k:
            mx.append(xx)
            my.append(yy - k)
        else:
            x.append(xx)
            y.append(yy)

graph = [[0 for _ in range(k)] for __ in range(k)]

#累積和
#lx + lmx = n
lx = len(x)
graph[0][0] += lx
for i in range(lx):
    graph[x[i]][0] -= 1
    graph[0][y[i]] -= 1
    graph[x[i]][y[i]] += 2

lmx = len(mx)
graph[0][0] -= lmx
for i in range(lmx):
    graph[mx[i]][0] += 1
    graph[0][my[i]] += 1
    graph[mx[i]][my[i]] -= 2

for i in graph:
    for j in range(k-1):
        i[j+1] += i[j]

for i in range(k):
    for j in range(k-1):
        graph[j+1][i] += graph[j][i]

#最大値、最小値を取得
big = max([max(i) for i in graph]) + lmx
small = min([min(i) for i in graph]) - lx

if big + small >= 0:
    print(big)
else:
    print(-small)
### BUGGY CODE ###

N = int(input())
A = [int(x) for x in input().split()]

MOD = 10**9 + 7

result = 0
for i in range(N):
    for j in range(i+1, N):
        add_target = (A[i] * A[j]) % MOD
        result = (result + add_target) % MOD

print(result)


### FIXED CODE ###

from itertools import accumulate

N = int(input())
A = list([int(x) for x in input().split()])
check = list(accumulate(A))

MOD = 10**9 + 7

result = 0
for i in range(N):
    result += (A[i] * (check[N-1] - check[i]))
    result %= MOD

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

n = int(input())
c = list(map(int,input().split()))
mod = 10**9+7
c.sort()
ans = 0
for i in range(n):
    ans += c[i]*(2+n-1-i)*4**(n-1)
    ans %= mod

ans %= mod
print(ans)

### FIXED CODE ###

n = int(input())
c = list(map(int,input().split()))
mod = 10**9+7
c.sort()
ans = 0
for i in range(n):
    ans += c[i]*(2+n-1-i)*pow(4,n-1,mod)
    ans %= mod

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

# coding: utf-8

import sys
input = sys.stdin.readline

def f(n, wv, W):
    dp = [0] * (W + 1)
    for wi, vi in wv:
        for w in range(W, wi - 1, -1):
            dp[w] = max(dp[w], dp[w - wi] + vi)
    return(dp[-1])

n, w = map(int, input().split()) # 1 <= n <= 100, 1 <= w <= 10^5
wv = [[int(x) for x in input().split()] for _ in range(n)]

print(f(n, wv, w))


### FIXED CODE ###

# coding: utf-8
import sys
input = sys.stdin.readline

def f(n, wlimit):
    dp = [-1] * (wlimit + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        wi, vi = map(int, input().rstrip().split())
        dp_ = list(dp)
        for w in range(wlimit + 1):
            if dp[w] >= 0:
                w_ = w + wi
                v_ = dp[w] + vi
                if w_ <= wlimit and dp[w_] < v_:
                    dp_[w_] = v_
        dp = dp_
    return(max(dp))

n, w = map(int, input().rstrip().split()) # 1 <= n <= 100, 1 <= w <= 10^5

print(f(n, w))
### BUGGY CODE ###

# atcoder https://atcoder.jp/contests/dp/tasks/dp_d
def main():
    N, W = map(int, input().split())
    w, v = [], []
    for _ in range(N):
        wi, vi = map(int, input().split())
        w.append(wi)
        v.append(vi)


    dp = [[0 for j in range(W+1)] for i in range(N+1)]

    for i in range(1, N+1):
        for j in range(1, W+1):
            if j >= w[i-1]:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]]+v[i-1])
            else:
                dp[i][j] = dp[i-1][j]

    print(dp[N][W])

main()

### FIXED CODE ###

# https://atcoder.jp/contests/dp/tasks/dp_d

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, W = MAP()
w, v = [], []
for _ in range(N):
    wi, vi = MAP()
    w.append(wi)
    v.append(vi)

DP = [[0] * (N+1) for _ in range(W+1)]

for i in range(1, W+1):
    for j in range(1, N+1):
        if i < w[j-1]:
            DP[i][j] = max(
                DP[i][j-1],
                DP[i-1][j])
        else:
            DP[i][j] = max(
                DP[i][j-1],
                DP[i-w[j-1]][j-1] + v[j-1],
                DP[i-1][j])

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

k = int(input())

maxV = (10**6)**2

i = 0
sevens = 0
while True:
    sevens = sevens * 10 + 7
    sevens = sevens % k
    i+=1
    if sevens % k == 0:
        print(i)
        exit()

print(-1)

### FIXED CODE ###

k = int(input())

maxV = (10**6)**2

i = 0
sevens = 0
while i < 10**6+1:
    sevens = sevens * 10 + 7
    sevens = sevens % k
    i+=1
    if sevens % k == 0:
        print(i)
        exit()

print(-1)
### BUGGY CODE ###

N = int(input())

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

for i in range(N):
	for j in range(N):
		if i+1 == A[j]:
			B.append(j+1)

for i in range(N):
	print(B[i])

### FIXED CODE ###

N = int(input())

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

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

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

import numpy as np
n = int(input())
aa = np.array(list(map(int, input().split())))
bb = list(map(int, input().split()))
cc = np.array(list(map(int, input().split())))
cnt = 0
for b in bb:
    na = (aa < b).sum()
    nc = (cc > b).sum()
    cnt += na*nc
print(cnt)

### FIXED CODE ###

import numpy as np
import bisect
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

aa.sort()
cc.sort()

cnt = 0
for b in bb:
    na = bisect.bisect_left(aa,b)
    nc = n - bisect.bisect_right(cc,b)
    cnt += na*nc
print(cnt)
### BUGGY CODE ###

s=list(input())
q=int(input())
r=1
for i in range(q):
    data=input().split()
    if(len(data)==1):
        r*=-1
    elif(data[1]=="1"):
        if(r==1):
            s.insert(0,data[2])
        else:
            s.append(data[2])
    else:
        if(r==1):
            s.append(data[2])
        else:
            s.insert(0,data[2])

if(r==-1):
    s.reverse()
print(''.join(s))

### FIXED CODE ###

s=list(input())
q=int(input())
start=[]
owari=[]
r=1
for i in range(q):
    data=input().split()
    if(len(data)==1):
        r*=-1
    elif(data[1]=="1"):
        if(r==1):
            start.append(data[2])
        else:
            owari.append(data[2])
    else:
        if(r==1):
            owari.append(data[2])
        else:
            start.append(data[2])

if(r==1):
    start.reverse()
    print(''.join(start),end='')
    print(''.join(s),end='')
    print(''.join(owari),end='')
else:
    owari.reverse()
    s.reverse()
    print(''.join(owari),end='')
    print(''.join(s),end='')
    print(''.join(start),end='')
### BUGGY CODE ###

s = input()
q = int(input())

reverse_status = False

for i in range(q):
  query = list(map(format, input().split()))
  if int(query[0]) == 1:
    if reverse_status:
      reverse_status = False
    else:
      reverse_status = True
  else:
    if int(query[1]) == 1:
      if reverse_status:
        s = s + query[2]
      else:
        s = query[2] + s
    else:
      if reverse_status:
        s = query[2] + s
      else:
        s = s + query[2]

if reverse_status:
  print(s[::-1])
else:
  print(s)

### FIXED CODE ###

from collections import deque

s = deque()
s.extend(list(input()))
q = int(input())

reverse_status = False

for i in range(q):
  query = list(map(format, input().split()))
  if int(query[0]) == 1:
    if reverse_status:
      reverse_status = False
    else:
      reverse_status = True
  else:
    if int(query[1]) == 1:
      if reverse_status:
        s.append(query[2])
      else:
        s.appendleft(query[2])
    else:
      if reverse_status:
        s.appendleft(query[2])
      else:
        s.append(query[2])

if reverse_status:
  s.reverse()
print(''.join(s))
### BUGGY CODE ###

k, s = map(int, input().split(' '))
cnt_pattern = 0
for a in range(k+1):
  for b in range(k+1):
    for c in range(k+1):
      if s == a + b + c:
        cnt_pattern += 1
        if s < a + b + c:
          break
print(cnt_pattern)

### FIXED CODE ###

k, s = map(int, input().split(' '))
cnt_pattern = 0
for a in range(k + 1):
  for b in range(k + 1):
    if 0 <= s - a - b <= k:
      cnt_pattern += 1
print(cnt_pattern)
### BUGGY CODE ###

import numpy as np
import itertools

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

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 ###

N = int(input())
a = [[input(), 1]]
for i in range(N-1):
  p = input()
  f = 0
  for n in range(len(a)):
    if a[n][0] == p:
      a[n][1] = a[n][1] + 1
      f = 1
      break
  if f == 0:
    a.append([p, 1])
MAX = 0
MAX_n = []
for n in range(len(a)):
  if a[n][1] == MAX:
    MAX_n.append(a[n][0])
  elif a[n][1] > MAX:
    MAX = a[n][1]
    MAX_n = [a[n][0]]
MAX_n.sort()
for i in MAX_n:
  print(i)

### FIXED CODE ###

N = int(input())
d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1
mx = 0
for i in d.values():
  mx = max(mx, i)
for i in sorted(d.items()):
  if i[1] == mx:
    print(i[0])
### BUGGY CODE ###

import math
N = int(input())
P_List = list(map(float,input().split()))
dp = []
for i in range(N):
    Current_Fault_P,Current_Correct_P = 1-P_List[i],P_List[i]
    if i == 0:
        dp.append([Current_Fault_P,Current_Correct_P])
    else:
        dp.append([])
        for j in dp[i-1]:
            dp[i].append(round(j*Current_Fault_P,10))
            dp[i].append(round(j*Current_Correct_P,10))

Standard = math.ceil(N/2)
Ans = 0
for k in range(len(dp[-1])):
    if bin(k).count("1") >= Standard:
       Ans += dp[-1][k]

print(round(Ans,10))

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_i
import math
N = int(input())
P_List = list(map(float,input().split()))
dp = [[0 for j in range(N + 1)] for i in range(N+1)]
std = math.ceil(N/2)
for i in range(N+1):
    if i == 0:
        dp[i][0] = 1
    else:
        Current_P = P_List[i - 1]
        for j in range(i + 1):
            if (N - i + j) < std:
                dp[i][j] = 0
            elif j == 0:
                dp[i][j] = dp[i - 1][j]*(1 - Current_P)
            elif j != i:
                dp[i][j] = (dp[i - 1][j]*(1 - Current_P)) + (dp[i - 1][j - 1]*Current_P)
            else:
                dp[i][j] = dp[i - 1][j - 1]*Current_P
    
print(sum(dp[N][math.ceil(std):]))
### BUGGY CODE ###

n,k = map(int,input().split())
hlist = [int(input())for i in range(n)]
hlist.sort()
dlist = [0]*(n-1)

for i in range(n-1):
  dlist[i] = hlist[i+1]-hlist[i]

ans = float('inf')
i = 0
while i+(k-1) <= n-1:
  ans = min(ans, sum((dlist[j]for j in range(i,k-1+i))))
  i += 1
print(ans)



### FIXED CODE ###

n,k = map(int,input().split())
hlist = sorted([int(input())for i in range(n)])

ans = 10**9
i = 0

while i+(k-1) <= n-1:
  ans = min(ans, hlist[k+i-1]-hlist[i])
  i += 1

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

from collections import defaultdict
N,P=map(int,input().split())
S=input()

if P==2 or P==5:
    ans=0
    for i in range(N):
        if int(S[i])%P==0:
            ans+=i+1
    print(ans)

else:
    d=defaultdict(int)
    a=0
    for i in range(N):
        a+=int(S[N-i-1])*10**i
        a%=P
        d[a]+=1
    ans=d[0]
    for v in d.values():
        ans+=v*(v-1)//2
    print(ans)
    


### FIXED CODE ###

from collections import defaultdict
N,P=map(int,input().split())
S=input()

if P==2 or P==5:
    ans=0
    for i in range(N):
        if int(S[i])%P==0:
            ans+=i+1
    print(ans)

else:
    d=defaultdict(int)
    a=0
    for i in range(N):
        a+=int(S[N-i-1])*pow(10,i,P)
        a%=P
        d[a]+=1
    ans=d[0]
    for v in d.values():
        ans+=v*(v-1)//2
    print(ans)