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

n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
#print(a)

for i in range(n-1):
    for j in range(i+1, n):
        if a[j] > a[i] + 2:
            #print(i, j)
            if (j - i) > ans:
                ans = (j - i)
            break
print(ans)

### FIXED CODE ###

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

N = int(input())
X = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(sorted(X[:i] + X[i+1:])[(N-1)//2])
print('\n'.join(map(str, A)))

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
l, r = Y[N//2-1], Y[N//2]
A = []
for i in range(N):
    if X[i] <= l:
        A.append(r)
    else:
        A.append(l)
print('\n'.join(map(str, A)))
### BUGGY CODE ###

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

for i in range(N):
  B[i] = A.index(i+1) + 1
  
  
print(*B)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B = list(A)
count = 1
for i in A:
  B[i-1] = count
  count+=1
  
  
print(*B)
### BUGGY CODE ###

n = int(input())
s = list(input())
m = n

for i in range(n):
    w = s[:i]
    e = s[i + 1:]
    count = w.count('W') + e.count('E')
    m = min(m, count)

print(m)

### FIXED CODE ###

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

reS = S[::-1]

wSum = [0 for i in range(N)]
eSum = [0 for i in range(N)]

for i in range(N):
    if i == 0:
        if S[i] == 'W':
            wSum[i] = 1
        if reS[i] == 'E':
            eSum[i] = 1
    else:
        if S[i] == 'W':
            wSum[i] = wSum[i-1] + 1
        else:
            wSum[i] = wSum[i-1]
        if reS[i] == 'E':
            eSum[i] = eSum[i-1] + 1
        else:
            eSum[i] = eSum[i-1]

eSum = eSum[::-1]

cost = eSum[1]

for i in range(1,N):
    if i == N - 1:
        if cost > wSum[N-2]:
            cost = wSum[N-2]
    else:
        if cost > wSum[i-1] + eSum[i+1]:
            cost = wSum[i-1] + eSum[i+1]
print(cost)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    
if ans > 10**18:
        print(-1)
        exit()

print(ans)


### FIXED CODE ###

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

if 0 in a:
    print(0)
    exit()
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()

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

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

#targetまでの素数の数
import math
def sieve_of_eratosthenes2(target):
    dest = int(math.sqrt(target))
    target_list = [i for i in range(2, target+1) if target%i==0]
    prime_list = []
 
    while True:
        num_min = min(target_list)
        if num_min > dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)        
        target_list = [i for i in target_list if i%num_min!=0]
        if target_list==[]:
            break
 
    return prime_list


a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    lis = sieve_of_eratosthenes2(gcd)
    ans = len(lis) + 1
    print(ans)


### FIXED CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a


import random
def is_prime(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q % 2 == 0:
        return False

    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

def prime_num(target):
    ra = 2
    prime = 0
    while target>1:
        if target%ra == 0:
            prime += 1
            while target%ra==0:
                target = target//ra
            if is_prime(target):
                prime += 1
                break
        if ra == 2:
            ra += 1
        else:
            ra += 2
    return prime   
        
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
elif is_prime(gcd):
    print(2)
else:
    ans = prime_num(gcd)    
    print(ans+1)
### BUGGY CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mmax = 0
pre = False
num = 0
for i in range(N+1):
  ans = 0
  if i == 0:
    ans = 0
  else:
    ans = sum(A[:i])
  if ans > K:
    break
  for j in range(M+1):
    temp = ans
    if j == 0:
      ans += 0
    else:
      ans += sum(B[:j])
    if ans > K:
      break
    else:
      mmax = max(mmax, i+j)
    ans = temp

print(mmax)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a = [0]
b = [0]
for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)
### BUGGY CODE ###

import numpy as np

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

ans=0
#print(a%(np.array([a for _ in range(n)])).transpose())

for i in range(n):
  b=a[i]%a==0
  #print(b)
  if np.count_nonzero(b)==1:
    ans+=1
print(ans)


### FIXED CODE ###

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

n=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6+2)
ans=0
for a in A:
  if cnt[a]!=0:
    cnt[a]=2
    continue
  x=a
  while x<10**6+2:
    cnt[x]+=1
    x+=a
for a in A:
  #print(cnt[a])
  if cnt[a]==1:
    ans+=1
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())

gates = list(range(1, N + 1))
for m in range(M):
  L, R = map(int, input().split())
  gates = [g for g in gates if L <= g and g <= R]
  if len(gates) < 1:
    break

print(len(gates))


### FIXED CODE ###

N, M = map(int, input().split())

gates = [[1, N]]

for m in range(M):
  L, R = map(int, input().split())
  updated = []
  for gate in gates:
    if L <= gate[0]:
      if gate[0] <= R:
        updated.append([gate[0], min(gate[1], R)])
    else:
      if L <= gate[1]:
        updated.append([L, min(gate[1], R)])
  gates = updated


print(sum([g[1] - g[0] + 1 for g in gates]))
### BUGGY CODE ###

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

ans = N
for i in range(N + 1):
    ans = min(ans, (S[:i].count('#') + S[i:].count('.')))
print(ans)

### FIXED CODE ###

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

all_black_num = S.count('#')
all_white_num = N - all_black_num

if all_black_num == 0 or all_white_num == 0:
    ans = 0
else:
    left_black_num = 0
    left_white_num = 0
    right_white_num = all_white_num - left_white_num
    right_black_num = all_black_num - left_black_num
    ans = left_black_num + right_white_num
    for i, c in enumerate(S):
        if c == '#':
            left_black_num += 1
        elif c == '.':
            left_white_num += 1
        right_white_num = all_white_num - left_white_num
        right_black_num = all_black_num - left_black_num
        ans = min(ans, left_black_num + right_white_num)
        if right_black_num == N - i - 1:
            break
print(ans)
### BUGGY CODE ###

n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())
mozi.sort()
li = list()

for i in mozi:
    if not i in li:
        li.append(i)
kazu = list()

for i in li:
    kazu.append(mozi.count(i))

m = [i for i ,x in enumerate(kazu) if x == max(kazu)]

for i in m:
    print(li[i])

### FIXED CODE ###

import collections

n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())

c = collections.Counter(mozi)
m = max(c.values())
c = sorted(c.items())

for i in c:
    if (i[1] == m):
        print(i[0])
### BUGGY CODE ###

import sys
input = sys.stdin.readline


if __name__ == "__main__":
    n = int(input())
    s_array = [''.join(sorted(input()[:-1])) for _ in range(n)]

    count = 0
    for i in range(n):
        for j in range(i+1, n):
            if(s_array[i] == s_array[j]):
                count += 1

    print(count)


### FIXED CODE ###

import sys
input = sys.stdin.readline


if __name__ == "__main__":
    n = int(input())
    s_array = [''.join(sorted(input()[:-1])) for _ in range(n)]

    s_array.sort()
    ans = 0
    count = 0
    word = s_array[0]
    for i in range(1, n):
        if(word == s_array[i]):
            count += 1
        else:
            ans += (count*(count+1))//2
            count = 0
        word = s_array[i]

    ans += (count*(count+1))//2
    print(ans)
### BUGGY CODE ###

N, Q = map(int, input().split())

S = [None] * N
T = [None] * N
X = [None] * N
for i in range(N):
    S[i], T[i], X[i] = map(int, input().split())

D = [None] * Q
for i in range(Q):
    D[i] = int(input())
    
# X S T
roadworks = [(x, s, t) for x, s, t in zip(X, S, T)]
roadworks = sorted(roadworks)
#print(roadworks)

# Dは入力時点でソート済み
walkers = D[:]
ans = dict()
import bisect
for x, s, t in roadworks:
    left = bisect.bisect_left(walkers, s - x)
    right = bisect.bisect_left(walkers, t - x)
    #print(left, right)
    for i in range(left, right):
    #   #print(i)
        ans[walkers[i]] = x
    walkers = walkers[:left] + walkers[right:]
    
#print(walkers)
for d in D:
    if d in ans:
        print(ans[d])
    else:
        print(-1)
    




    
    


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, Q = map(int, input().split())

S = [None] * N
T = [None] * N
X = [None] * N
for i in range(N):
    S[i], T[i], X[i] = map(int, input().split())

D = [None] * Q
for i in range(Q):
    D[i] = int(input())
    
# X S T
roadworks = [(x, s, t) for x, s, t in zip(X, S, T)]
roadworks = sorted(roadworks, key=lambda x: x[0])
#print(roadworks)

# Dは入力時点でソート済み
walkers = D[:]
ans = [-1] * Q
skip = [-1] * Q

import bisect
for x, s, t in roadworks:
    left = bisect.bisect_left(walkers, s - x)
    right = bisect.bisect_left(walkers, t - x)
    
    i = left
    while i < right:
        if skip[i] == -1:
            ans[i] = x
            skip[i] = right
            i += 1
        else:
            i = skip[i]

    
#print(walkers)
for a in ans:
    print(a)
### BUGGY CODE ###

n, m = map(int, input().split())
card=[0 for _ in range(n)]
for i in range(m):
    l, r = map(lambda x: int(x)-1, input().split())
    for i in range(l,r+1):
        card[i]+=1
print(card.count(m))


### FIXED CODE ###

n, m = map(int, input().split())
card=[0 for _ in range(n)]
l, r = map(int, input().split())
l-=1
for i in range(m-1):
    li, ri = map(int, input().split())
    li-=1
    if li>r or ri<l:
        l=r
        break
    elif li>=l and ri<=r:
        l=li; r=ri
    elif li<=l and ri>=r:
        pass
    elif li<=r and ri>=r:
        l=li
    elif ri>=l and li<=l:
        r=ri
    else:
        pass
print(r-l)
### BUGGY CODE ###

# ABC121D - XOR World
def main():
    a, b = list(map(int, input().rstrip().split()))
    ans = a
    for i in range(a + 1, b + 1):
        ans ^= i
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC121D - XOR World
def main():
    a, b = list(map(int, input().rstrip().split()))
    c = a if a % 2 == 0 else a + 1
    n = b - c + 1
    pairs = n // 2
    if n % 2 == 0:
        ans = pairs % 2
        ans ^= 0 if c == a else a
        print(ans)
    else:
        ans = (pairs % 2) ^ b
        ans ^= 0 if c == a else a
        print(ans)


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

k = int(input())

import math
import itertools
num_list = list(list(itertools.product(range(1,k+1), repeat=3)))

sum_ = 0
for i,j,k in num_list:
    sum_ += math.gcd(i, math.gcd(j, k))
    
print(sum_)

### FIXED CODE ###

k = int(input())
from math import gcd
sum_ = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for k in range(1, k+1):
            sum_ += gcd(i, gcd(j, k))
print(sum_)
### BUGGY CODE ###

N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key = lambda x: x[2])
X.append([-1, 1, X[-1][2] + 1])

def quitConst(t):
  nextx = [x for x in X if x[1] > t + x[2] or x[0] == -1]
  return nextx

for _ in range(Q):
  current = 0
  start = int(input())
  X = quitConst(start)
  for x in X:
    current = x[2]
    if x[0] <= current + start < x[1]:
      break
  if current == X[-1][2]:
    print(-1)
  else:
    print(current)

### FIXED CODE ###

from bisect import bisect_left as bl
N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key = lambda x: x[2])
Y = [int(input()) for _ in range(Q)]
res = [-1] * Q
jump = [-1] * Q
for s,t,x in X:
  l=bl(Y,s - x)
  r=bl(Y,t - x)
  while l < r:
    s = jump[l]
    if s == -1:
      res[l] = x
      jump[l] = r
      l += 1
    else:
      l = s
print(*res,sep = '\n')
### BUGGY CODE ###

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

for _ in range(M):

    max_A = max(A)
    ind = A.index(max_A)
    A[ind] = max_A//2

print(sum(A))

### FIXED CODE ###

import heapq
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))

heapq.heapify(A)


for _ in range(M):
    a = heapq.heappop(A)
    a = -(-a//2)
    heapq.heappush(A,a)

print(-1*sum(A))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

dp = [0] * n

for i in range(1, n):
    min_cost = 1e19
    # for j in range(1, min(k + 1, i + 1)):
    #     cost = dp[i - j] + abs(hs[i] - hs[i - j])
    #     min_cost = min(cost, min_cost)
    costs = [
        dp[i - j] + abs(hs[i] - hs[i - j])
        for j in range(1, min(k + 1, i + 1))
    ]
    dp[i] = min(costs)

print(dp[n - 1])


### FIXED CODE ###

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

dp = [0] * n

for i in range(1, n):
    costs = []
    for j in range(1, k + 1):
        if i - j >= 0:
            cost = dp[i - j] + abs(hs[i] - hs[i - j])
            costs.append(cost)
    dp[i] = min(costs)

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

MOD = 10**9 + 7

N = int(input())
S = input().rstrip()

is_left = [(i%2 == 0) ^ (x == "W") for i, x in enumerate(S)]

answer = 1
left = 0
for bl in is_left:
    if bl:
        left += 1
    else:
        answer *= left
        left -= 1


if left != 0:
    answer = 0
    
for i in range(1, N+1):
    answer *= i
    answer %= MOD

print(answer)

### FIXED CODE ###

MOD = 10**9 + 7

N = int(input())
S = input().rstrip()

is_left = [(i%2 == 0) ^ (x == "W") for i, x in enumerate(S)]

answer = 1
left = 0
for bl in is_left:
    if bl:
        left += 1
    else:
        answer *= left
        left -= 1
        answer %= MOD

if left != 0:
    answer = 0
    
for i in range(1, N+1):
    answer *= i
    answer %= MOD

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

def main():
    N , M, K = map(int, input().split())
    A_list = [A for A in input().split()]
    B_list = [B for B in input().split()]
    A_list = list(map(int, A_list))
    B_list = list(map(int, B_list))

    al = [0]
    bl = [0]

    for i in range(N) :
        al.append(al[i] + A_list[i])
    for i in range(M) :
        bl.append(bl[i] + B_list[i])
    #print("al = %s" % al)
    #print("bl = %s" % bl)
    re = M
    ans = 0
    book = []

    for i in range(N+1) :
        re = M
        if al[i] > K :
            continue
        for j in range(M+1) :
            ans = al[i] + bl[re]
            #print(ans)
            re -= 1
            if ans <= K :
                book.append(i + re + 1)
                break

    print(max(book))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N , M, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))

    al = [0]
    bl = [0]

    for i in range(N) :
        al.append(al[i] + A_list[i])
    for i in range(M) :
        bl.append(bl[i] + B_list[i])
    #print("al = %s" % al)
    #print("bl = %s" % bl)
    book = 0
    re = M

    for i in range(N+1) :
        if al[i] > K :
            break
        #for j in range(M+1) :
        #    if bl[re] <= K - al[i] :
        #        break
        #    else :
        #        re -= 1
        while bl[re] > K - al[i] :
            re -= 1

        book = max(book, i + re)

    print(book)


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

S = input()
N = int(input())
Q =[]
flag = True
while True:
    try:
        Q.append(list(map(str,input().split())))

    except:
        break;

for i in range(N):
    if Q[i][0]=="1":
        flag = not(flag)                
    else: 
        if Q[i][1] == "2" and flag == True:
            S += Q[i][2]#先頭
            
        
        elif Q[i][1] == "2" and flag == False:
            S1 = Q[i][2]+ S
            S = S1
            
        elif Q[i][1] == "1" and flag == True:
            S1 = Q[i][2]+S
            S = S1
            
        elif Q[i][1] == "1" and flag == False:
            S += Q[i][2]

if flag == True:
    print(S)
else:
    print(S[::-1])  

### FIXED CODE ###

from sys import stdin
S = input()
x = S
y =str()   
N = int(input())
Q =  [list(map(str, stdin.readline().split())) for _ in range(N)]
flag = True
for i in range(N):
    if Q[i][0]=="1":
        flag = not(flag)                
    else: 
        if (Q[i][1] == "2") == (flag == True):
            x += Q[i][2]#先頭
        else :
            y += Q[i][2]
M = "".join([y[::-1],x])
if flag == True:
    print(M)
else:
    print(M[::-1])
### BUGGY CODE ###

import sys
import math
from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = II()
S = input()

ans = 0
for i in range(1, N-2):
    for j in range(1+i, N):
        #if j <= i:
        #    continue
        for k in range(1+j, N+1):
            #if k <= j:
            #    continue
            if not(j-i == k-j or S[i-1] == S[j-1] or S[i-1] == S[k-1] or S[k-1] == S[j-1]):
                ans+=1
print(ans)

### FIXED CODE ###

import sys
import math
from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
  for j in range(i+1,N-1):
    k=2*j-i
    if k>=N:
      continue
    if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
      ans-=1
print(ans)
### BUGGY CODE ###

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

ans = 0

for i in range(n):
    for j in range(n):
        if i < j:
            ans += a[i] * a[j]
            ans %= (10**9 + 7)


print(ans)

### FIXED CODE ###

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

ans = 0

a_goketi = sum(a)
b = []

for i in range(n):
    b.append(a_goketi - a[i])
    a_goketi -= a[i]

    ans += a[i] * b[i] 

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

import numpy as np
N = int(input())
a = np.array([int(item) for item in input().split()], dtype=int)

cum = np.cumsum(a)
total = np.sum(a)
def find(b, total):
    assert sum(b)==total
#     print("b: ", b)
    thre = total/2.0
    b = np.cumsum(b)
    out = np.argmin(np.abs(b-thre))
#     print("out:", out)
    return out
#     return np.min(np.where(b>thre)[0])

best = total
for i in range(1,N-2):
    left = cum[i]
    right = total - left
    ileft = find(a[:(i+1)], left)
    iright = find(a[(i+1):], right) + i + 1
    z1 = np.sum(a[:(ileft+1)])
    z2 = left - z1
    z3 = np.sum(a[(i+1):(iright+1)])
    z4 = np.sum(a[(iright+1):])  # right - z3
    M = max([z1,z2,z3,z4])
    m = min([z1,z2,z3,z4])
    best = min(best, M-m)
#     print([z1,z2,z3,z4])
print(best)

### FIXED CODE ###

# ARC100D

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))


# import numpy as np
import bisect
n = int(input())
a = list(map(int, input().split()))
# a = np.array(list(map(int, input().split())))
ca = [None] * n #ca[i] = a0~aiの和
s = 0
for i,num in enumerate(a):
    s += a[i]
    ca[i] = s
# ca = a.cumsum()

def sub(l, start, end, init):
    if len(l)==0:
        return 0,0
    elif end-start==1:
        return 0,l[start]-init
    target = (init + l[end-1])/2
    i = bisect.bisect_right(l, target)
    p1 = (l[i]-init, l[end-1]-l[i])
    p2 = (l[i-1]-init, l[end-1]-l[i-1])
    if abs(p1[0] - p1[1]) < abs(p2[0] - p2[1]):
        return min(p1), max(p1)
    else:
        return min(p2), max(p2)
best = 10**15
for i in range(1,n):
    p1 = sub(ca, 0, i, 0)
    p2 = sub(ca, i, n, ca[i-1])
    nn = max(p1[1]-p2[0], p2[1]-p1[0], p1[1]-p1[0], p2[1]-p2[0])
#     print(p1,p2,nn)
    best = min(best, nn)
print(best)
### BUGGY CODE ###

n=int(input())

l=1
f=False
while True:
    j=l+1
    for i in range(1,l+1):
        if n == i*(j-i):
            print(j-2)
            f=True
            break
    l+=1
    if f:
        break


### FIXED CODE ###

import math

n = int(input())
ans = n-1
x = int(math.ceil(math.sqrt(n)))

for i in range(1, x+1):
    if n%i == 0:
        ans = int(min(ans, i+n/i-2))

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

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

point = [k] * n
for i in a:
    for j in range(n):
        if i-1 != j:
            point[j] -= 1

for i in range(n):
    if point[i] <= 0:
        print("No")
    else:
        print("Yes")


### FIXED CODE ###

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

count = [k - q] * n
for i in a:
    count[i-1] += 1

for i in range(n):
    if count[i] <= 0:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(a[i])
    b.reverse()
print(" ".join(map(str,b)))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.reverse()
ans=[]
re_ans=[]
if n==1:
    print(a[0])
else:
    ans=a[::2]
    re_ans=a[1::2]
    re_ans.reverse()
    ans.extend(re_ans)
    map_ans=map(str,ans)
    v=" ".join(map_ans)
    print(v)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

for i in range(1,n+1):
  z = a.index(i)
  l.append(z+1)
  
print(*l)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
List = [0]*N
 
 
for i, a in enumerate(A):
  List[int(a)-1] = str(i+1)
 
  
print(" ".join(List))