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

from collections import deque

H,W = map(int,input().split())
C_h,C_w = map(lambda x:int(x)-1,input().split())
D_h,D_w = map(lambda x:int(x)-1,input().split())
S = [input() for _ in range(H)]

INF = int(1e7)
dist = [[INF]*(W) for _ in range(H)]
dist[C_h][C_w] = 0
deq = deque()
deq.append((C_h,C_w))

move_a = [(1, 0), (0, 1), (-1, 0), (0, -1)]
move_b = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (0, -2), (0, 2), (1, -2), (1, -1), (1, 1), (1, 2), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]

while len(deq):
  h,w = deq.popleft()
  for dh,dw in move_a:
    nh,nw = h+dh,w+dw
    if nh>=0 and nw>=0 and nh<H and nw<W and S[nh][nw]!='#' and dist[nh][nw] > dist[h][w]:
      dist[nh][nw] = dist[h][w]
      deq.appendleft((nh,nw))
  for dh,dw in move_b:
    nh,nw = h+dh,w+dw
    if nh>=0 and nw>=0 and nh<H and nw<W and S[nh][nw]!='#' and dist[nh][nw] > dist[h][w]+1:
      dist[nh][nw] = dist[h][w]+1
      deq.append((nh,nw))

print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)


### FIXED CODE ###

from collections import deque

H,W = map(int,input().split())
C_h,C_w = map(lambda x:int(x)-1,input().split())
D_h,D_w = map(lambda x:int(x)-1,input().split())
S = [input() for _ in range(H)]

INF = int(1e10)
dist = [[INF]*(W) for _ in range(H)]
deq = deque()
deq.append((C_h,C_w,0))

move_a = [(1,0),(0,1),(-1,0),(0,-1)]
move_b = [(i,j)for i in range(-2,2+1) for j in range(-2,2+1) if abs(i)+abs(j)>=2]

while len(deq):
  h,w,c = deq.popleft()
  if dist[h][w] <= c:
    continue
  dist[h][w] = c
  for dh,dw in move_a:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c:
      deq.appendleft((nh,nw,c))
  for dh,dw in move_b:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c+1:
      deq.append((nh,nw,c+1))
  
print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)
### BUGGY CODE ###

from collections import deque
def solve():
    N, M, P = map(int, input().split())
    G = [[] for i in range(N)]
    RG = [[] for i in range(N)]
    for i in range(M):
        a, b, c = map(int, input().split())
        G[a-1].append((b-1, P-c))
        RG[b-1].append((a-1, P-c))

    def chk(s, G):
        P = [0]*N
        que = deque([s])
        used = [0]*N
        used[s] = 1
        while que:
            v = que.popleft()
            P[v] = 1
            for w, c in G[v]:
                if used[w]:
                    continue
                que.append(w)
                used[w] = 1
        return P
    P0 = chk(0, G); P1 = chk(N-1, RG)
    F = [P0[i] == P1[i] == 1 for i in range(N)]
    I = [i for i in range(N) if F[i]]

    G0 = [[] for i in range(N)]
    for v in range(N):
        if not F[v]:
            continue
        for w, c in G[v]:
            if not F[w]:
                continue
            G0[v].append((w, c))

    dist = [10**18]*N
    dist[0] = 0
    L = len(I)
    for i in range(L):
        update = 0
        for v in I:
            d = dist[v]
            for w, c in G0[v]:
                if d + c < dist[w]:
                    dist[w] = d + c
                    update = 1
        if not update:
            break
    else:
        print("-1")
        return

    print(max(-dist[N-1], 0))
solve()

### FIXED CODE ###

from collections import deque
N, M, P = map(int, input().split())
G = [[] for i in range(N)]
RG = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    G[a-1].append((b-1, P-c))
    RG[b-1].append((a-1, P-c))

def chk(s, G):
    P = [0]*N
    que = deque([s])
    used = [0]*N
    used[s] = 1
    while que:
        v = que.popleft()
        P[v] = 1
        for w, c in G[v]:
            if used[w]:
                continue
            que.append(w)
            used[w] = 1
    return P
P0 = chk(0, G); P1 = chk(N-1, RG)
I = [i for i in range(N) if P0[i] == P1[i] == 1]

dist = [10**18]*N
dist[0] = 0
L = len(I)
for i in range(L+1):
    update = 0
    for v in I:
        d = dist[v]
        for w, c in G[v]:
            if d + c < dist[w]:
                dist[w] = d + c
                update = 1
    if not update:
        break
else:
    print("-1")
    exit(0)

print(max(-dist[N-1], 0))
### BUGGY CODE ###

H, W = map(int, input().split())

P = [ [ 0 if x == "#" else 0x00010001 for x in input()] for _ in range(H)]

class Union:
    def __init__(self):
        self.rx = 0
        self.ry = 0
        self.lx = 0
        self.ly = 0
    def init(self, y, x):
        value = P[y][x]
        if value == 0:
            return False

        self.lx = x
        self.ly = y
        w = value & 0xffff
        if w & 0x8000:
            self.ry = w ^ 0x8000
        else:
            self.ry = self.ly

        w = value >> 16
        if w & 0x8000:
            self.rx = w ^ 0x8000
        else:
            self.rx = self.lx

        return True

    def changeH(self, src, value):
        return (src ^ (src & 0xffff0000)) | (value << 16)
    def changeV(self, src, value):
        return (src ^ (src & 0xffff)) | value

    def changeHA(self, value):
        return self.changeH(value, self.rx | 0x8000)
    def changeVA(self, value):
        return self.changeV(value, self.ry | 0x8000)

    def getHC(self):
        return P[self.ly][self.rx] >> 16
    def setHC(self, value):
        P[self.ly][self.rx] = self.changeH(P[self.ly][self.rx], value)
    def getVC(self):
        return P[self.ry][self.lx] & 0xffff
    def setVC(self, value):
        P[self.ry][self.lx] = self.changeV(P[self.ry][self.lx], value)
        
uni = Union()

for i in range(H):
    for j in range(W):
        if P[i][j] != 0:
            if i > 0 and uni.init(i-1, j):
                uni.setVC(uni.getVC() + 1)
                P[i][j] = uni.changeVA(P[i][j])
            if j > 0 and uni.init(i, j-1):
                uni.setHC(uni.getHC() + 1)
                P[i][j] = uni.changeHA(P[i][j])


w = 0
for i in range(H):
    for j in range(W):
        if uni.init(i, j):
            w = max(w, uni.getHC() + uni.getVC() -1)

print(w)


### FIXED CODE ###

H, W = map(int, input().split())

P = [[0 if x == "#" else 1 for x in input()] for _ in range(H)]
C = [[-3*P[x][y] for y in range(W)] for x in range(H)]

for j in range(W):
    cntU = 0
    cntD = 0
    for i in range(H):
        if P[i][j] == 0:
            cntD = 0
        else:
            cntD += 1
        C[i][j] += cntD 

        if P[H-1-i][j] == 0:
            cntU = 0
        else:
            cntU += 1
        C[H-1-i][j] += cntU 

for i in range(H):
    cntR = 0
    cntL = 0
    for j in range(W):
        if P[i][j] == 0:
            cntR = 0
        else:
            cntR += 1
        C[i][j] += cntR 

        if P[i][W-1-j] == 0:
            cntL = 0
        else:
            cntL += 1
        C[i][W-1-j] += cntL 




print(max((x for ci in C for x in ci)))
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A_array = list(map(int, input().split()))
B_array = list(map(int, input().split()))
C_array = list(map(int, input().split()))

A_array.sort()
B_array.sort()
C_array.sort()

use_array = []
sum_array = []
candidate_array = []

max_sum = A_array[-1] + B_array[-1] + C_array[-1]

candidate_array = [[X - 1, Y - 1, Z - 1, max_sum]]

use_array.append((X - 1, Y - 1, Z - 1))

for i in range(K):
    candidate_array = sorted(candidate_array, key=lambda x: -x[3])

    x, y, z, s = candidate_array.pop(0)

    sum_array.append(s)
    if x != 0 and (x - 1, y, z) not in use_array:
        use_array.append((x - 1, y, z))
        diff = A_array[x] - A_array[x - 1]
        candidate_array.append([x - 1, y, z, s - diff])

    if y != 0 and (x, y - 1, z) not in use_array:
        use_array.append((x, y - 1, z))
        diff = B_array[y] - B_array[y - 1]
        candidate_array.append([x, y - 1, z, s - diff])

    if z != 0 and (x, y, z - 1) not in use_array:
        use_array.append((x, y, z - 1))
        diff = C_array[z] - C_array[z - 1]
        candidate_array.append([x, y, z - 1, s - diff])

for ans in sum_array:
    print(ans)

### FIXED CODE ###

import heapq
X, Y, Z, K = map(int, input().split())
A_array = list(map(int, input().split()))
B_array = list(map(int, input().split()))
C_array = list(map(int, input().split()))

A_array.sort()
B_array.sort()
C_array.sort()

use_array = []
sum_array = []

candidate = []
heapq.heapify(candidate)

max_sum = A_array[-1] + B_array[-1] + C_array[-1]

heapq.heappush(candidate, (0, X - 1, Y - 1, Z - 1))
use_array.append((X - 1, Y - 1, Z - 1))

for i in range(K):
    s, x, y, z = heapq.heappop(candidate)

    sum_array.append(s)
    if x != 0 and (x - 1, y, z) not in use_array:
        use_array.append((x - 1, y, z))
        diff = A_array[x] - A_array[x - 1]
        heapq.heappush(candidate, (s + diff, x - 1, y, z))

    if y != 0 and (x, y - 1, z) not in use_array:
        use_array.append((x, y - 1, z))
        diff = B_array[y] - B_array[y - 1]
        heapq.heappush(candidate, (s + diff, x, y - 1, z))

    if z != 0 and (x, y, z - 1) not in use_array:
        use_array.append((x, y, z - 1))
        diff = C_array[z] - C_array[z - 1]
        heapq.heappush(candidate, (s + diff, x, y, z - 1))

for ans in sum_array:
    print(max_sum - ans)
### BUGGY CODE ###

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

import random
import time
from bisect import bisect_left

L_len = len(L)
L.sort()

count = 0
for i in range(0, L_len - 2):
    for j in range(i + 1, L_len - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length, lo = j + 1, hi = L_len)
        count += idx - j - 1

print(count)


### FIXED CODE ###

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

from bisect import bisect_left

L.sort()

count = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length)
        count += idx - j - 1

print(count)
### BUGGY CODE ###

# 蟻本1-6-1例題相当
# 数学的に解けそうであるが、とりあえず3重のfor文で回してみる
# 最大で2500^3≒100億となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

count = 0
k, s = map(int,input().split())
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z == s:
        count += 1
print(count)

### FIXED CODE ###

# 蟻本1-6-1例題相当
# 続いて、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

count = 0
k, s = map(int,input().split())
for x in range(k+1):
  for y in range(k+1):
    if 0 <= s-x-y and s-x-y <= k:
        count += 1
print(count)
### BUGGY CODE ###

N,K = map(int,input().split())
XY = list(list(map(int,input().split()))for i in range(N))

ans = float('inf')

for i in range(N):
    lx = XY[i][0]
    for j in range(N):
        rx = XY[j][0]
        for k in range(N):
            dy = XY[k][1]
            for l in range(N):
                uy = XY[l][1]
                hoge = 0
                for x,y in XY:
                    if lx <= x and rx >= x and uy >= y and dy <= y:
                        hoge += 1
                if hoge >= K:
                    ans = min(ans,(rx-lx)*(uy-dy))
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
XY = []

for i in range(N):
    x,y = map(int,input().split())
    XY.append((x,y))


ans = float('inf')

for lx, _ in XY:
    for rx, _ in XY:
        if lx > rx:
            continue
        for _, dy in XY:
            for _, uy in XY:
                if dy > uy:
                    continue
                count = 0
                for x,y in XY:
                    if lx <= x <= rx and dy <= y <= uy:
                        count += 1
                if count >= K:
                    ans = min(ans,(rx-lx)*(uy-dy))
print(ans)
### BUGGY CODE ###

from collections import deque
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
blacklist = []
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            blacklist.append((h,w))
count = 0
alr = [[0 for i in range(W)] for j in range(H)]
h1 = [0,0,1,-1]
w1 = [1,-1,0,0]
for h,w in blacklist:
    que = deque()
    que.append((h,w,True))
    alr[h][w] = 1
    alr2 = [(h,w)]
    while que:
        hn,wn,black = que.popleft()
        black = not black
        for i in range(4):
            if 0 <= hn+h1[i] <= H-1 and 0 <= wn+w1[i] <= W-1 and (hn+h1[i],wn+w1[i]) not in alr2:
                if (not black) and S[hn+h1[i]][wn+w1[i]] == '.':
                    if not alr[hn+h1[i]][wn+w1[i]]:
                        count += 1
                    que.append((hn+h1[i],wn+w1[i],black))
                    alr2.append((hn+h1[i],wn+w1[i]))
                elif black and S[hn+h1[i]][wn+w1[i]] == '#':
                    que.append((hn+h1[i],wn+w1[i],black))
                    alr2.append((hn+h1[i],wn+w1[i]))
print(count)
                        

### FIXED CODE ###

from collections import deque
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
blacklist = []
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            blacklist.append((h,w))
ans = 0
alr = [[0 for i in range(W)] for j in range(H)]
h1 = [0,0,1,-1]
w1 = [1,-1,0,0]
for h,w in blacklist:
    if alr[h][w] == 0:
        bcount = 1
        wcount = 0
        que = deque()
        que.append((h,w,True))
        alr[h][w] = 1
        while que:
            hn,wn,black = que.popleft()
            black = not black
            for i in range(4):
                if 0 <= hn+h1[i] <= H-1 and 0 <= wn+w1[i] <= W-1 and not alr[hn+h1[i]][wn+w1[i]]:
                    if (not black) and S[hn+h1[i]][wn+w1[i]] == '.':
                        wcount += 1
                        que.append((hn+h1[i],wn+w1[i],black))
                        alr[hn+h1[i]][wn+w1[i]] = 1
                    elif black and S[hn+h1[i]][wn+w1[i]] == '#':
                        bcount += 1
                        que.append((hn+h1[i],wn+w1[i],black))
                        alr[hn+h1[i]][wn+w1[i]] = 1
        ans += wcount*bcount
print(ans)
### BUGGY CODE ###

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

r = 0
asum = [0]

for i in A:
    asum.append(asum[-1] + i)    

for i in range(len(A)):
    Axor = A[i]
    for j in range(i, len(A)):
        if ( i == j ):
            r += 1
        else:
            Axor = Axor ^ A[j]
            if (asum[j+1] - asum[i]) == Axor:
                r += 1
            else:
                break

print(r)

### FIXED CODE ###

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

res = 0
asum = [0]
axor = [0]

for i in A:
    asum.append(asum[-1] + i)
    axor.append(axor[-1] ^ i)

for l in range(N):
    ok = l+1
    ng = N+1
    while(ng - ok > 1):
        r = (ok + ng) // 2
        s = (axor[r] ^ axor[l])
        t = (asum[r] - asum[l])
        if s == t:
            ok = r
        else:
            ng = r
    
    res += ok - l
         
print(res)
### BUGGY CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
dp = [1] * (max(a)+9)
for num in a:
    for i in range(num*2, max(a) + 9, num):
        dp[i] = 0
ans = 0
count = Counter(a)
for num in a:
    if count[num] == 1:
        ans += dp[num]
print(ans)


### FIXED CODE ###

from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
MAX = 1000000 + 9
dp = [True] * MAX
for num in a:
    for i in range(num*2, MAX, num):
        dp[i] = False
ans = 0
for num in a:
    if dp[num] and a[num] == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

import copy
n = int(input())
a = [int(i) for i in input().split()]
aa = copy.deepcopy(a)
c=0
for ind_,i in enumerate(a):
  f=0
  for ind_2,j in enumerate(aa):
    if ind_==ind_2:
      continue
    if i<j:
      continue
    if i%j==0:
      f=1
      break
  if f==0:
    c+=1
print(c)

### FIXED CODE ###


N=int(input())
A=list(map(int,input().split()))
dp=[False]*(10**6+1)
A.sort()
ans=0
before_ = -1
for i in A:
  if dp[i]==False:
    for j in range(2*i,10**6+1,i):
      dp[j]=True
  if before_ == i:
      dp[i]=True
  before_=i

for i in A:
  if dp[i]==False:
    ans+=1
print(ans)
### BUGGY CODE ###

L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        ans = min((i*j) % 2019, ans)
    if ans == 0:
        break
print(ans)


### FIXED CODE ###

L, R = map(int, input().split())
R = min(R, L+4038)
ans = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        ans = min((i*j) % 2019, ans)
print(ans)
### BUGGY CODE ###

s = input()
iteration = int(input())

for c in range(0,iteration):
    sousa = input().split()
    if sousa[0] == "1":
        s = s[:: -1]
    elif sousa[1] == "1":
        s = sousa[2] + s
    else:
        s = s + sousa[2]
print(s)

### FIXED CODE ###

from collections import deque
string = input()
s = deque(string)
iteration = int(input())
reverse = 1

for c in range(0,iteration):
    sousa = input().split()
    #操作１のとき
    if sousa[0] == "1":
        reverse = reverse*(-1)
    #操作２を行うとき
    elif sousa[1] == "1":
        if reverse == 1:
            s.appendleft(sousa[2])
        else:
            s.append(sousa[2])
    else:
        if reverse == 1:
            s.append(sousa[2])
        else:
            s.appendleft(sousa[2])

result = "".join(s)
if reverse == -1:
    result = result[::-1]


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

import sys
input = sys.stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


n, q = map(int, input().split())
c = list(map(int, input().split()))

rli = []
for i in range(q):
    l, r = map(int, input().split())
    l, r = l, r
    rli.append((r, l, i))
rli.sort()

last = [-1] * (n + 1)

bit = Bit(n)
ans = [0] * q
cur = 1
for r, l, i in rli:
    for j in range(cur, r + 1):
        if last[c[j - 1]] != -1:
            bit.add(last[c[j - 1]], -1)
        last[c[j - 1]] = j
        bit.add(j, 1)
    cur = r + 1
    ans[i] = bit.sum(r) - bit.sum(l - 1)
print(*ans, sep="\n")


### FIXED CODE ###

import sys
input = sys.stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0 for _ in range(n + 2)]
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


n, q = map(int, input().split())
c = list(map(int, input().split()))

rli = []
for i in range(q):
    l, r = map(int, input().split())
    rli.append((r, l, i))
rli.sort(key=lambda x: x[0])

last = [-1 for _ in range(n + 1)]

bit = Bit(n)
ans = [-1 for _ in range(q)]
cur = 1
for r, l, i in rli:
    for j in range(cur, r + 1):
        if last[c[j - 1]] != -1:
            bit.add(last[c[j - 1]], -1)
        last[c[j - 1]] = j
        bit.add(j, 1)
    cur = r + 1
    ans[i] = bit.sum(r) - bit.sum(l - 1)
print(*ans, sep="\n")
### BUGGY CODE ###

import math
import numpy as np
n=int(input())
lis=[]
ans=[]
for i in range(n):
    lis.append(input())
    ans.append([0,0,0,0,0,0,0,0,0,0])
    for j in range(10):
        ans[i][j]=lis[i][j]
    ans[i].sort()

ans.sort()
a=np.zeros(n)
for i in range(n-1):
    for j in range(n-1-i):
        if ans[i]==ans[i+j+1]:
            a[i]+=1
        else:
            break
b=0
for i in range(n):
    b+=a[i]

print(int(b))


### FIXED CODE ###

n=int(input())
ans=[]
for i in range(n):
    qw=input()
    ans.append([0,0,0,0,0,0,0,0,0,0])
    for j in range(10):
        ans[i][j]=qw[j]
    ans[i].sort()

lis=[]
for i in range(n):
    lis.append(ans[i][0])
    for j in range(9):
        lis[i]+=ans[i][j+1]

a=0
#print(lis)

dic={lis[0]:1}
for i in range(n-1):
    if lis[i+1] in dic.keys():
        a+=dic[lis[i+1]]
        dic[lis[i+1]]+=1
    else:
        dic[lis[i+1]]=1

print(int(a))
### BUGGY CODE ###

N,K = map(int,input().split())
big_array = []
for i in range(N):
    a,b = map(int,input().split())
    for j in range(b):
        big_array.append(a)
big_array.sort()
print(big_array[K-1])

### FIXED CODE ###

N,K = map(int,input().split())
ab = []
for i in range(N):
    a,b = map(int,input().split())
    ab.append([a,b])
ab.sort()
while K > 0:
    for _ab in ab:
        K -= _ab[1]
        if K <= 0:
            print(_ab[0])
            break
### BUGGY CODE ###

import numpy as np

N, K = map(int, input().split())
hs = np.array(list(map(int, input().split())))

i = 0
total_cost = 0
 
a = np.zeros(N, int)
a[0] = 0
a[1] = abs(hs[1] - hs[0])

for i in range(2, N):
    bmin = float('inf')
    for j in range(K):
        if i-j+1 >= 0:
        	bmin = min(bmin, a[max(i-(j+1),0)] + abs(hs[i] - hs[max(i-(j+1),0)]))    
        else:
        	break
    a[i] = bmin
print(a[-1])


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
hs = np.array(list(map(int, input().split())))

i = 0
total_cost = 0
 
a = np.zeros(N, dtype=np.int64)
a[0] = 0
a[1] = abs(hs[1] - hs[0])

for i in range(2, N):
    k = min(K,i)
    a[i] = np.min(a[i-k:i] + np.abs(hs[i] - hs[i-k:i]))    
print(a[-1])
### BUGGY CODE ###

n = int(input())
dat = list(map(int, input().split()))
res = 0
dat.sort(reverse=True)
for a in range(n):
    for b in range(a+1, n):
        if dat[a] >= (dat[b] * 2):
            break
        for c in range(b+1, n):
            if dat[a] < (dat[b] + dat[c]) and dat[b] < (dat[c] + dat[a]) and dat[c] < (dat[a] + dat[b]):
                res += 1
            else:
                break
print(res)


### FIXED CODE ###

import bisect
n = int(input())
dat = list(map(int, input().split()))
dat.sort(reverse=True)
dat = list(map(lambda x: -x, dat))
#print(dat)
res = 0
for a in range(n):
    #print("a={0}, [{1}]".format(dat[a],a))
    for b in range(a+1, n):
        #print("b={0}, [{1}]".format(dat[b],b))
        cind = bisect.bisect_left(dat, dat[a] - dat[b], b)
        cannum = cind - (b+1)
        cannum = 0 if cannum < 0 else cannum
        #print("cind", cind)
        #print("cannum", cannum)
        res += cannum
print(res)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
def u(a, b):
    if b == 0:
        return a
    return u(b, a % b)

if len(A) <= 2:
    res = max(A)
else:
    res = 0
    for i in range(len(A)):
        tmp = list(A)
        if tmp.index(tmp[i]) < i:
            continue
        tmp.pop(i)
        for k in range(len(tmp)-1):
            tmp[k+1] = u(tmp[k], tmp[k+1])
        res = max(res, tmp[len(tmp)-1])
print(res)


### FIXED CODE ###

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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

res = [0] * N
l = [0] * (N + 1)
r = [0] * (N + 1)

for i in range(N):
    l[i+1] = gcd(l[i], A[i])

for i in range(N, 0, -1):
    r[i-1] = gcd(r[i], A[i-1])

for i in range(N):
    res[i] = gcd(l[i], r[i+1])

print(max(res))