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

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


for i in range(N):
    a = X[:i] + X[i+1:]
    med = sorted(a)[(N//2)-1]
    print(med)

### FIXED CODE ###

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

SORTED = sorted(X)
med1 = SORTED[N//2 - 1]
med2 = SORTED[N//2]
# print(med1, med2)

for xi in X:
    if xi <= med1:
        print(med2)
    else:
        print(med1)
### BUGGY CODE ###

import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

print("\n".join(sorted([ k for k,v in c.items() if v == max(c.values()) ])))

### FIXED CODE ###

import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

u = max(c.values())
print("\n".join(sorted([ k for k,v in c.items() if v == u ])))
### BUGGY CODE ###

# https://atcoder.jp/contests/abc164/tasks/abc164_d

S = input()
L = len(S)
res = 0

T = [0]

for i in range(1,L+1):
    """ 累積和 """
    T.append(int(S[L-i:]))

reminder = [0]*2019
for i in range(L+1):
    reminder[T[i]%2019] += 1

for c in reminder:
    res += c*(c-1)//2

print(res)

### FIXED CODE ###

# https://atcoder.jp/contests/abc164/tasks/abc164_d

from operator import mul
from functools import reduce
from collections import defaultdict

def combination(n, r):
    if not 0 <= r <= n: return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

S = input()

res = 0

T = [0]
x = 0
L = len(S)
for i, s in zip(range(L),reversed(S)):
    """ 累積和 """
    x = (int(s)*pow(10,i,2019) + x)%2019
    T.append(x)

reminder = [0]*2019
for i in range(L+1):
    reminder[T[i]%2019] += 1

for c in reminder:
    res += combination(c,2)

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

import sys

n, k = map(int, input().split())
h_list = list(map(int, input().split()))

cost = [sys.maxsize] * n
cost[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        if i+j < n:
            diff = int(abs(h_list[i] - h_list[i+j]))
            cost[i+j] = min(cost[i]+diff, cost[i+j])
print(cost[n-1])

### FIXED CODE ###

import sys

n, k = map(int, input().split())
h_list = list(map(int, input().split()))

cost = [sys.maxsize] * n
cost[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        if i+j < n:
            diff = int(abs(h_list[i] - h_list[i+j]))
            cost[i+j] = min(cost[i]+diff, cost[i+j])
print(cost[n-1])
### BUGGY CODE ###

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

for k in range(int(round(y/1000, 0)) + 1):
    for j in range(int(round(y/5000, 0)) + 1):
        for i in range(int(round(y/10000, 0)) + 1):
            if (10000*i) + (5000*j) + (1000*k) > y or i+j+k > n:
                break
            elif (10000*i) + (5000*j) + (1000*k) == y and i+j+k == n:
                print(i, j, k)
                exit()

print("-1 -1 -1")

### FIXED CODE ###

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

for i in range(n+1):
    for j in range(n-i+1):
        if (10000*i) + (5000*j) + (1000*(n-i-j)) == y:
            print(i, j, n-i-j)
            exit()

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

K ,S = map(int,input().split())
count = 0
for x in range(S+1):
    if(x > K):
        continue
    for y in range(S+1):
        if(y > K):
            continue
        for z in range(S+1):
            if(z > K):
                continue
            if(x+y+z==S):
                count+=1
print(count)

### FIXED CODE ###

K,S = map(int, input().split())
count = 0
for i in range(K,-1,-1):
    if i <= S:
        z = i
        sum_xy = S - i
        for j in range(K, -1,-1):
            if j <= sum_xy:
                y = j
                if sum_xy - j <= K:
                    count += 1
    else:
        continue
print(count)
### BUGGY CODE ###

N = int(input())
P = [float(p) for p in input().split()]

DP = [[0 for n in range(N+1)] for _ in range(N)]
DP[0][0] = 1-P[0]
DP[0][1] = P[0]

for i in range(1, N):
    use = P[i]
    DP[i][0] = DP[i-1][0] * (1-use)
    for j in range(1, i+2):
        DP[i][j] = DP[i-1][j] * (1-use) + DP[i-1][j-1] * use

print(sum(DP[N-1][N//2+1:]))



### FIXED CODE ###

N = int(input())
P = [float(p) for p in input().split()]

DP = [[0 for n in range(N+1)] for _ in range(N)]
DP[0][0] = 1-P[0]
DP[0][1] = P[0]

for i in range(1, N):
    use = P[i]
    DP[i][0] = DP[i-1][0] * (1-use)
    for j in range(1, i+2):
        DP[i][j] = DP[i-1][j] * (1-use) + DP[i-1][j-1] * use

print(sum(DP[N-1][N//2+1:]))
### BUGGY CODE ###

from collections import deque
import copy
def solve(maze, start):
  memo = [[False]*len(maze[0]) for _ in range(len(maze))]
  q = deque()
  q.append([start,0])
  ans = 0
  while q:
    cur, cnt = q.popleft()
    ans = max(ans, cnt)
    memo[cur[0]][cur[1]] = True
    for y, x in zip((0,0,1,-1),(1,-1,0,0)):
      if maze[cur[0]+y][cur[1]+x] == "." and not memo[cur[0]+y][cur[1]+x]:
        q.append([[cur[0]+y,cur[1]+x],cnt+1])
  return ans

H, W = map(int, input().split())
Maze = [["#"]*(W+2)]+[["#"]+list(input())+["#"] for _ in range(H)] + [["#"]*(W+2)]
Ans = 0
sy = 1
while sy <= H:
  sx = 1
  while sx <= W:
    if Maze[sy][sx] == "#":
      continue
    else:
      Ans = solve(Maze, [sy, sx])
    sx += 1
  sy+= 1
print(Ans)

### FIXED CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]


def f(i, j):
    t = [[-1] * W for _ in range(H)]
    t[i][j] = 0
    q = [(i, j)]
    while q:
        y, x = q.pop(0)
        if y - 1 >= 0 and S[y - 1][x] != '#' and t[y - 1][x] == -1:
            t[y - 1][x] = t[y][x] + 1
            q.append((y - 1, x))
        if y + 1 < H and S[y + 1][x] != '#' and t[y + 1][x] == -1:
            t[y + 1][x] = t[y][x] + 1
            q.append((y + 1, x))
        if x - 1 >= 0 and S[y][x - 1] != '#' and t[y][x - 1] == -1:
            t[y][x - 1] = t[y][x] + 1
            q.append((y, x - 1))
        if x + 1 < W and S[y][x + 1] != '#' and t[y][x + 1] == -1:
            t[y][x + 1] = t[y][x] + 1
            q.append((y, x + 1))
    return max(max(tt) for tt in t)


result = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            result = max(result, f(i, j))
print(result)
### BUGGY CODE ###

d = []
n = int(input())
for i in range(n):
    a = input()
    if a not in d:
        d.append(a)
print(len(d))

### FIXED CODE ###

d = set()
n = int(input())
for i in range(n):
   d.add(input())
print(len(d))
### BUGGY CODE ###

from itertools import permutations


def main():
    N, M, R = map(int, input().split())
    r = map(int, input().split())
    d = [[float('inf') for j in range(N)] for i in range(N)]
    for i in range(N):
        d[i][i] = 0

    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        t = min(c, d[a][b])
        if d[a][b] > c:
            d[a][b], d[b][a] = t, t

    for i in range(N):
        for j in range(N):
            for k in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    ans = float('inf')
    for i in permutations(r):
        temp = 0
        for j in range(R - 1):
            temp += d[i[j] - 1][i[j + 1] - 1]
            if temp > ans:
                break
        ans = min(ans, temp)

    print(ans)


main()


### FIXED CODE ###

from itertools import permutations

def main():
    N, M, R = map(int, input().split())
    r = map(int, input().split())
    inf = float('inf')
    d = [[inf] * N for i in range(N)]

    for i in range(N):
        d[i][i] = 0

    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        if d[a][b] > c:
            d[a][b], d[b][a] = c, c

    for k in range(N):
        for i in range(N):
            for j in range(N):
                temp = d[i][k] + d[k][j]
                if d[i][j] > temp:
                    d[i][j] = temp

    ans = inf
    for i in permutations(r):
        temp = 0
        for j in range(len(i)-1):
            temp += d[i[j] - 1][i[j + 1] - 1]
            if temp > ans:
                break
        if ans > temp:
            ans = temp

    print(ans)


main()
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
 
for i in range(n):
  temp = a[i]
  a[i] = 0
  print(max(a))
  a[i] = temp

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
b_max = b[-1]
b.pop(-1)
b_2max = b[-1]

for i in a:
    if i == b_max:
        print(b_2max)
    else:
        print(b_max)
### BUGGY CODE ###

from bisect import bisect_left as bl
from collections import deque as dq
X, Y, Z, K = map(int, input().split())
ABC = [sorted(list(map(int, input().split()))) for _ in range(3)]
AB = []
for i in range(X):
  for j in range(Y):
    AB.append(ABC[0][i] + ABC[1][j])
AB.sort(reverse = True)
res = []
for i in range(min(K, X * Y)):
  for j in range(Z):
    res.append(AB[i] + ABC[2][j])
res.sort(reverse = True)
for i in range(K):
  print(res[i])

### FIXED CODE ###

from bisect import bisect_left as bl
from collections import deque as dq
X, Y, Z, K = map(int, input().split())
ABC = [sorted(list(map(int, input().split()))) for _ in range(3)]
AB = []
for i in range(X):
  for j in range(Y):
    AB.append(ABC[0][i] + ABC[1][j])
AB.sort(reverse = True)
res = []
for i in range(min(K, X * Y)):
  for j in range(Z):
    res.append(AB[i] + ABC[2][j])
res.sort(reverse = True)
for i in range(K):
  print(res[i])
### BUGGY CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
md = make_divisors(N)
mdd = make_divisors(N-1)
se = set(md+mdd)
li = list(se)
ans = 0
for i in li:
  if i != 1:
    n = N
    while n >= i:
      if n % i == 0:
        n = n // i
      else:
        n = n - i
    if n == 1:
      ans += 1
print(ans)

### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
md = make_divisors(N)
mdd = make_divisors(N-1)
se = set(md + mdd)
li = list(se)
ans = 0
for i in li:
  if i != 1:
    n = N
    while n >= i:
      if n % i == 0:
        n = n // i
      else:
        n = n % i
    if n == 1:
      ans += 1
print(ans)
### BUGGY CODE ###

import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_ = [int(input()) for _ in range(N)]

    for i in range(N):
        L = A_[0:i]
        L.extend(A_[i + 1:])
        print(max(L))
        
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_ = [int(input()) for _ in range(N)]

    max_A = max(A_)
    if A_.count(max_A) > 1:
        for i in range(N):
            print(max_A)
            
    else:
        for i in range(N):
            if A_[i] == max_A:
                L = A_[0:i]
                L.extend(A_[i+1:])
                print(max(L))
            else:
                print(max_A)

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

k, s = map(int, input().split())

counter = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        for z in range(0, k + 1):
            if x + y + z == s:
                counter += 1

print(counter)

### FIXED CODE ###

k, s = map(int, input().split())

counter = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        if 0 <= s - x - y <= k: 
                counter += 1

print(counter)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,S=map(int,input().split())
A=list(map(int,input().split()))

mod=998244353

DP=[0]*(S+1)
DP[0]=pow(2,N,mod)

INV=pow(2,mod-2,mod)

for a in A:
    for i in range(S-a,-1,-1):
        DP[i+a]=(DP[i]*INV+DP[i+a])%mod
        
print(DP[S])


### FIXED CODE ###

import sys
input = sys.stdin.readline

N,S=map(int,input().split())
A=list(map(int,input().split()))

mod=998244353

DP=[0]*(S+1)
DP[0]=pow(2,N,mod)

INV=pow(2,mod-2,mod)

for a in A:
    for i in range(S-a,-1,-1):
        DP[i+a]=(DP[i]*INV+DP[i+a])%mod
        
print(DP[S])
### BUGGY CODE ###

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int,ss_raw()))

X,Y,Z,K = ints_raw()

A = ints_raw()
B= ints_raw()
C= ints_raw()

arg_buf = {}
def main():
    D = [a+b for a in A for b in B]
    D.sort(reverse=True)
    E = [D[d]+c for d in range(min(K,len(D))) for c in C]
    E.sort(reverse=True)
    for k in range(K):
        print(E[k])

main()


### FIXED CODE ###

from heapq import *

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int,ss_raw()))

X,Y,Z,K = ints_raw()

A = ints_raw()
B= ints_raw()
C= ints_raw()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

arg_hash = {}

def main():
    Q = []
    heappush(Q,(-A[0]-B[0]-C[0],0,0,0))
    arg_hash[(0,0,0)]=1
    for k in range(K):
        ans = heappop(Q)
        print(-ans[0])
        a,b,c = ans[1:]

        argA = (a+1,b,c)
        if a < X-1 and (not argA in arg_hash):
            arg_hash[argA]=1
            heappush(Q,(-A[a+1]-B[b]-C[c],)+argA)
        argB = (a,b+1,c)
        if b < Y-1 and (not argB in arg_hash):
            arg_hash[argB]=1
            heappush(Q, (-A[a]-B[b+1]-C[c],)+argB)
        argC = (a,b,c+1)
        if c < Z-1 and (not argC in arg_hash):
            arg_hash[argC]=1
            heappush(Q,(-A[a]-B[b]-C[c+1],)+argC)
        
main()
### BUGGY CODE ###

N = int(input())

def main1(N):
    lst = list()
    count = 0
    for i in range(1, N+1):
        for j in range(i, N+1):
            ahead = int(str(i)[0])
            atail = i % 10
            bhead = int(str(j)[0])
            btail = j % 10
            if ahead == btail and atail == bhead:
                count += (1 if i == j else 2)
    print(count)

def main2(N):
    #9*9の表
    lst = list()
    for i in range(1,10):
        lst.append([0]*9)

    for n in range(1, N+1):
        for i in range(1,10):
            for j in range(1,10):
                head = str(n)[0]
                tail = str(n)[-1]
                if i == int(head) and j == int(tail):
                    lst[i-1][j-1] += 1
    
    count = 0
    for i in range(0, len(lst)):
        for j in range(0, len(lst[i])):
            count += lst[i][j] * lst[j][i]

    print(count)

main2(N)


### FIXED CODE ###

def main3(N):
    lst = list()
    for i in range(1, 10):
        lst.append([0]*9)

    for n in range(1, N+1):
        head = int(str(n)[0])
        tail = int(str(n)[-1])
        #末尾が0はNG
        if tail != 0:
            lst[head-1][tail-1] += 1
        
    #for i in range(0, len(lst)):
    #    print(lst[i])
    
    count = 0
    for i in range(0, len(lst)):
        for j in range(0, len(lst[i])):
            count += lst[i][j] * lst[j][i]

    print(count)

N = int(input())
main3(N)
### BUGGY CODE ###

n=int(input())
S=[sorted(list(input())) for i in range(n)]
ans=0

for i in range(n):
  for j in range(i+1,n):
    if S[i] == S[j]:
      ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
d = {}
ans = 0
for i in range(n):
    s = str(sorted(input()))
    if s in d:
        ans+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(ans)
### BUGGY CODE ###

N = int(input())
gachalist = []
for i in range(N):
    item = input()
    if item not in gachalist:
        gachalist.append(item)
print(len(gachalist))

### FIXED CODE ###

N = int(input())
gachalist=[]
for i in range(N):
    gachalist.append(input())
print(len(set(gachalist)))
### BUGGY CODE ###

n, a ,b = map(int, raw_input().split())
c = 0
for i in xrange(n):
    t = input()
    if not t in range(a,b):
        c += 1
print c

### FIXED CODE ###

n, a ,b = map(int, raw_input().split())
c = 0
for i in xrange(n):
    t = input()
    if not a <= t < b:
        c += 1
print c
### BUGGY CODE ###

import math
import fractions
from functools import reduce

def loop1(i, k, ans):
  global arr, result
  for ai in range(int(math.floor(k/arr[i])+1)):
    if (i+1<len(arr)):
      loop1(i+1, k-arr[i]*ai, ans+[ai])
    else:
      if arr[i]*ai==k:
        result=ans+[ai]
        break
  return result

def gcd(*arr):
  return reduce(fractions.gcd, arr)

def loop2(i, k, ans):
  global arr, result
  if k%gcd(*arr[i:len(arr)])==0:
    for ai in range(int(math.floor(k/arr[i])+1)):
      if i+1<len(arr):
        loop2(i+1, k-arr[i]*ai, ans+[ai])
      else:
        result=(ans+[ai])
        break
  return result


arr=[100, 101, 102, 103, 104, 105]
k=int(input())
result=""
loop2(0, k, [])
if result=="":
  print(0)
else:
  print(1)


### FIXED CODE ###

import math
import fractions
from functools import reduce

def loop1(i, k, ans):
  global arr, result
  for ai in range(int(math.floor(k/arr[i])+1)):
    if (i+1<len(arr)):
      loop1(i+1, k-arr[i]*ai, ans+[ai])
    else:
      if arr[i]*ai==k:
        result=ans+[ai]
        break
  return result

def gcd(*arr):
  return reduce(fractions.gcd, arr)

def loop2(i, k, ans):
  global arr, result
  if k%gcd(*arr[i:len(arr)])==0:
    for ai in range(int(math.floor(k/arr[i])+1)):
      if i+1<len(arr):
        loop2(i+1, k-arr[i]*ai, ans+[ai])
      else:
        result=(ans+[ai])
        break
  return result


arr=[100, 101, 102, 103, 104, 105]
k=int(input())
result=""
if k>=2200:
  print(1)
else:
  loop2(0, k, [])
  if result=="":
    print(0)
  else:
    print(1)
### BUGGY CODE ###

k = int(input())
ans = 0 #答え
i = 1 #数回す用
c = 0 #ルンルン数カウント

while c < k:
  j = str(i)
  if i < 13: #13未満なら
    c = c + 1 #ルンルン数
    #print(c, i)
  else: #それ以外なら
    x = 0
    for n in range(len(j)-1): #ルンルン数判定を行う
      if abs(int(j[n]) - int(j[n+1])) > 1:#桁の差が1より大きかったら
        x = 1
        break
    if x == 0:
      c = c + 1
      #print(c, i)
  i = i + 1 #iに1を足す

print(i-1)

### FIXED CODE ###

k = int(input())
lunlun = [1, 2, 3, 4, 5, 6, 7, 8, 9] #ルンルン数リスト

for i in range(k):
    x = lunlun[i]
    if x%10 != 0:
        lunlun.append(x*10+x%10-1)
    lunlun.append(x*10+x%10)
    if x%10 != 9:
        lunlun.append(x*10+x%10+1)
        #print(lunlun)
print(x)
### BUGGY CODE ###

import numpy as np
import itertools
H,W = map(int,input().split(' '))
bk = []
for i in range(H):
	t = input()
	bk.extend([(i,x) for x in range(W) if t[x] == '#'])
bk = np.array(bk)

ans = np.zeros((H,W)).astype(np.int)
for pos in itertools.product(range(H),range(W)):
	ans[pos] = np.min(np.linalg.norm(bk-pos,ord=1,axis=1))
print(np.max(ans))







### FIXED CODE ###

H,W = map(int,input().split(' '))
bk = []
for i in range(H):
	t = input()
	bk.extend([(x,i) for x in range(W) if t[x] == '#'])

mat = [[True]*H for i in [0]*W]
for x,y in bk:
	mat[x][y] = False

cnt = 0
al = len(bk)
while(True):
	if al == H*W:
		break
	new = []
	for x,y in bk:
		if x > 0 and mat[x-1][y]:
			mat[x-1][y] = False
			new.append((x-1,y))
		if x < W-1 and mat[x+1][y]:
			new.append((x+1,y))
			mat[x+1][y] = False
		if y > 0 and mat[x][y-1]:
			new.append((x,y-1))
			mat[x][y-1] = False
		if y < H-1 and mat[x][y+1]:
			new.append((x,y+1))
			mat[x][y+1] = False
	al += len(new)
	bk = new
	cnt += 1
print(cnt)
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

sys.setrecursionlimit(10**6)


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

    query = (map(int, readline().strip().split()) for _ in range(N-1))

    tree = [[] for _ in range(N)]
    for u, v in query:
        tree[u-1].append(v-1)
        tree[v-1].append(u-1)

    inf = 10 ** 9 + 7
    dp = [inf] * (N+1)
    ans = [0] * N

    def dfs(node, parent):
        v = As[node]
        lb = binary_search(dp, v)
        old = dp[lb]
        dp[lb] = v
        ans[node] = dp.index(inf)
        for child in tree[node]:
            if child == parent:
                continue
            dfs(child, node)
        dp[lb] = old

    dfs(0, 0)

    for k in range(N):
        print(ans[k])


def binary_search(seq, v):
    left = 0
    right = len(seq) - 1
    center = right // 2

    while left != right:
        if v <= seq[center]:
            right = center
        else:
            left = center+1
        center = (right + left) // 2

    return center


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
readline = sys.stdin.readline

sys.setrecursionlimit(10**6)


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

    query = (map(int, readline().strip().split()) for _ in range(N-1))

    tree = [[] for _ in range(N)]
    for u, v in query:
        tree[u-1].append(v-1)
        tree[v-1].append(u-1)

    inf = 10 ** 18
    dp = [inf] * (N+1)
    ans = [0] * N

    def dfs(node, parent):
        v = As[node]
        lb = binary_search(dp, v)
        old = dp[lb]
        dp[lb] = v
        ans[node] = binary_search(dp, inf)
        for child in tree[node]:
            if child == parent:
                continue
            dfs(child, node)
        dp[lb] = old

    dfs(0, 0)

    for k in range(N):
        print(ans[k])


def binary_search(seq, v):
    left = 0
    right = len(seq) - 1
    center = right // 2

    while left != right:
        if v <= seq[center]:
            right = center
        else:
            left = center+1
        center = (right + left) // 2

    return center


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

n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        k = j
        while k + 1 < n and l[k + 1] < l[i] + l[j]:
            k += 1
        cnt += k - j
print(cnt)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n):
    k = i + 1
    for j in range(i + 1, n):
        while k + 1 < n and l[k + 1] < l[i] + l[j]:
            k += 1
        cnt += k - j
print(cnt)
### BUGGY CODE ###

N = int(input())
S = input()

res = float("inf")

if "." not in S or "#" not in S:
    res = 0

for i in range(N):
    res = min(res, S[:i].count("#") + S[i:].count("."))

print(res)


### FIXED CODE ###

N = int(input())
S = input()

res = float("inf")

# if "#" not in S or "." not in S:
#     res = 0

counts = []
counts.append((0, 0))
a, b = 0, 0
for s in S:
    if s == "#":
        a += 1
    elif s == ".":
        b += 1
    counts.append((a, b))

for i in range(N + 1):
    res = min(res, counts[i][0] + counts[-1][1] - counts[i][1])

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


S = str(input())
Q = int(input())
query=[]

for line in range(Q):
	query.append(list(input().split()))
for i in range(Q):
	if query[i][0]=="1":
		S=S[::-1]
	else:
		if query[i][1]=="1":
			S=query[i][2]+S
		else:
			S=S+query[i][2]
print(S)




### FIXED CODE ###


S = str(input())
Q = int(input())
query=[]
a=""
b=""
# for line in range(Q):
# 	query.append(list(input().split()))
t=True

for i in range(Q):
	q=list(input().split())
	if int(q[0])==1:
		t= not t
	else:
		if int(q[1])==1:
			if t:
				a=q[2]+a
			else:
				b=b+q[2]

		else:
			if t:
				b=b+q[2]
			else:
				a=q[2]+a

if t:
	print(a+S+b)
else:
	print(b[::-1]+S[::-1]+a[::-1])
### BUGGY CODE ###

n, k = map(int,input().split())
P = list(map(lambda x:(int(x)+1)/2,input().split()))
S = []

for i in range(n-k+1):
    S.append(sum(P[i:i+k]))

print(max(S))

### FIXED CODE ###

from itertools import accumulate
n, k = map(int,input().split())
P = list(map(lambda x:(int(x)+1)/2,input().split()))
A = list(accumulate([0]+P))
B = []
for i in range(n-k+1):
    B.append(A[i+k]-A[i])

print(max(B))