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

n = int(input())
l_list = list(map(int,input().split()))
l_list.sort(reverse=True)
temp_sum = 0
check_break = 0
for i in range(n-2):
    check_break = 0
    for j in range(i+1,n-1):
        if check_break == 1:
            break
        # print(temp_sum)
        for k in range(j+1,n):
            if l_list[k] > l_list[i] - l_list[j]:
                temp_sum += 1
            elif k == j+1:
                check_break = 1
                break
            else:
                break


print(temp_sum)


### FIXED CODE ###

import bisect
n = int(input())
l_list = list(map(int,input().split()))
l_list.sort()
ans = 0
right = 0
# print(l_list)
for i in range(n-2):
    for j in range(i+1,n-1):
        right = bisect.bisect_left(l_list[j+1:],l_list[i]+l_list[j])
        # print(right)
        ans += right
        
print(ans)
### BUGGY CODE ###

# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        a = list(map(int, input().split()))

        ans = 0
        for x in range(10 ** 5 + 1):
            ans = max(ans, a.count(x - 1) + a.count(x) + a.count(x + 1))
        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


### FIXED CODE ###

# sys.stdin.readline
import collections
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        a = list(map(int, input().split()))

        cnt = collections.Counter(a)

        ans = 0
        for x in range(10 ** 5 + 1):
            ans = max(ans, cnt[x - 1] + cnt[x] + cnt[x + 1])
        print(ans)


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

from collections import deque

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

dist = [[float("inf")]*W for i in range(H)]
q = deque([])
for y in range(H) :
    for x in range(W) :
        if A[y][x] == "#" :
            dist[y][x] = 0
            q.append((y,x))

dxy = [(-1,0),(1,0),(0,-1),(0,1)]

while q :
    y,x = q.popleft()
    for dy,dx in dxy :
        ny,nx = y+dy,x+dx
        if ny<0 or ny>=H or nx<0 or nx>=W :
            continue
        if dist[ny][nx] > dist[y][x] + 1 :
            dist[ny][nx] = dist[y][x] + 1
            q.append((ny,nx))

ans = 0
for y in range(H) :
    ans = max(ans, max(dist[y]))
print(ans)


### FIXED CODE ###

from collections import deque

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

L = [[float("inf") for x in range(W)] for y in range(H)]



dxy = [(-1,0), (1,0), (0,-1), (0,1)]

Q = deque()

for y in range(H) :
    for x in range(W) :
        if A[y][x] != "#" :
            continue
        
        L[y][x] = 0
        
        Q.append((y,x))

while Q :
    y,x = Q.popleft()

    for dy,dx in dxy :
        ny = y+dy
        nx = x+dx

        if (ny < 0) or (ny >= H) or (nx < 0) or (nx >= W) :
            continue

        if L[ny][nx] <= (L[y][x] + 1) :
            continue
        
        L[ny][nx] = L[y][x] + 1
        
        Q.append((ny,nx))

ans = 0

for y in range(H) :
    ans = max(ans, max(L[y]))
print(ans)
### BUGGY CODE ###

n,m = map(int,input().split())
g = 1
for i in range(int(m/n),1,-1):
  if m%i == 0:
    g = i
    break
    
      
print(g)
  

### FIXED CODE ###

n,m = map(int,input().split())
g = 1
def fact(k):
  a = []
  for i in range(1,int(k **(0.5))+1):
    if k%i ==0:
      a.append(i)
      a.append(int(k/i))
  b = list(set(a))
  b.sort()
  return b

g = fact(m)
for i in range(len(g)):
  if g[len(g)-i-1] <= m/n:
    print(g[len(g)-i-1])
    break
### BUGGY CODE ###

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

UFT = UnionFind(N)
for _ in range(M):
    x, y = map(int,input().split())
    UFT.union(x-1, y-1)

ans = 0

for i in range(N):
    if P[i] - 1 in UFT.members(i):
        ans += 1
print(ans)

### FIXED CODE ###

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

UFT = UnionFind(N)
for _ in range(M):
    x, y = map(int,input().split())
    UFT.union(x-1, y-1)

ans = 0

for i in range(N):
    if UFT.same(P[i] - 1, i):
        ans += 1
print(ans)
### BUGGY CODE ###

def main():
    mod = 1000000007
    n, k = (int(x) for x in input().split())
    l = tuple(i for i in range(n + 1))  # おまけの小さい部分，でも大事
    ans = 0
    # 選ぶ数の数で分ける。でかい部分は無視して，
    # 最小値と最大値が分かれば取りうる値も分かる。
    for j in range(k, n + 2):
        _min = sum(l[:j])
        _max = sum(l[-j:])
        ans += _max - _min + 1
        ans %= mod
    return ans


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

def main():
    mod = 1000000007
    n, k = (int(x) for x in input().split())
    l = (i for i in range(n + 1))  # おまけの小さい部分，でも大事

    # 累積和を計算しておく，前からと後ろから。
    former = 0
    acm = tuple((former:= former + i) for i in range(n + 1))
    former = 0
    acm_rev = tuple((former:= former + i) for i in range(n, -1, -1))

    ans = 0
    # 選ぶ数の数で分ける。でかい部分は無視して，
    # 最小値と最大値が分かれば取りうる値も分かる。
    for j in range(k-1, n + 1):
        ans += acm_rev[j] - acm[j] + 1
        ans %= mod
    return ans


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

# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
N,M=map(int,input().split())
XYZ=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
ittenai=[]
for x,y,z in XYZ:
    data[x].append(y)
    data[y].append(x)
    ittenai.append(x)
    ittenai.append(y)


ittenai=set(ittenai)
count=N-len(ittenai)
while ittenai:
    x=list(ittenai)[0]
    stack=deque([x])
    ittenai.remove(x)
    count+=1
    while stack:
        num=stack.popleft()
        for i in data[num]:
            if i in ittenai:
                ittenai.remove(i)
                stack.append(i)
print(count)


### FIXED CODE ###

# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
N,M=map(int,input().split())
XYZ=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
ittenai=[]
for x,y,z in XYZ:
    data[x].append(y)
    data[y].append(x)
    ittenai.append(x)
    ittenai.append(y)


ittenai=set(ittenai)
count=N-len(ittenai)
while ittenai:
    x=ittenai.pop()
    stack=deque([x])

    count+=1
    while stack:
        num=stack.popleft()
        for i in data[num]:
            if i in ittenai:
                ittenai.remove(i)
                stack.append(i)
print(count)
### BUGGY CODE ###

H,W,K=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())

pond=[]
for _ in range(H):
    pond.append(list(input()))

inf=10**7
cost=[[inf]*W for _ in range(H)]
cost[x1][y1]=0
from heapq import heapify,heappop,heappush
hq=[(0,x1,y1)]

while hq:
    t,x,y=heappop(hq)
    #北へ
    for i in range(1,K+1):
        if x-i<0 or pond[x-i][y]=="@":
            break
        if cost[x-i][y]>t+1:
            cost[x-i][y]=t+1
            heappush(hq,(t+1,x-i,y))
    #東へ
    for i in range(1,K+1):
        if y+i>W-1 or pond[x][y+i]=="@":
            break
        if cost[x][y+i]>t+1:
            cost[x][y+i]=t+1
            heappush(hq,(t+1,x,y+i))
    #南へ
    for i in range(1,K+1):
        if x+i>H-1 or pond[x+i][y]=="@":
            break
        if cost[x+i][y]>t+1:
            cost[x+i][y]=t+1
            heappush(hq,(t+1,x+i,y))
    #西へ
    for i in range(1,K+1):
        if y-i<0 or pond[x][y-i]=="@":
            break
        if cost[x][y-i]>t+1:
            cost[x][y-i]=t+1
            heappush(hq,(t+1,x,y-i))

if cost[x2][y2]==inf:
    print(-1)
    exit()  
print(cost[x2][y2])

### FIXED CODE ###

H,W,K=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())

pond=[]
for _ in range(H):
    pond.append(list(input()))

inf=10**7
cost=[[inf]*W for _ in range(H)]
cost[x1][y1]=0
from heapq import heapify,heappop,heappush
hq=[(0,x1,y1)]

while hq:
    t,x,y=heappop(hq)
    #北へ
    for i in range(1,K+1):
        if x-i<0 or pond[x-i][y]=="@" or cost[x-i][y]<t+1:
            break
        if cost[x-i][y]>t+1:
            cost[x-i][y]=t+1
            heappush(hq,(t+1,x-i,y))
    #東へ
    for i in range(1,K+1):
        if y+i>W-1 or pond[x][y+i]=="@" or cost[x][y+i]<t+1:
            break
        if cost[x][y+i]>t+1:
            cost[x][y+i]=t+1
            heappush(hq,(t+1,x,y+i))
    #南へ
    for i in range(1,K+1):
        if x+i>H-1 or pond[x+i][y]=="@" or cost[x+i][y]<t+1:
            break
        if cost[x+i][y]>t+1:
            cost[x+i][y]=t+1
            heappush(hq,(t+1,x+i,y))
    #西へ
    for i in range(1,K+1):
        if y-i<0 or pond[x][y-i]=="@" or cost[x][y-i]<t+1:
            break
        if cost[x][y-i]>t+1:
            cost[x][y-i]=t+1
            heappush(hq,(t+1,x,y-i))

if cost[x2][y2]==inf:
    print(-1)
    exit()  
print(cost[x2][y2])
### BUGGY CODE ###

import sys

def solve():
    N = int(input())
    S = input()
    sdict = dict()
    lens = len(S)
    for i in range(lens): sdict[i] = S[i]
    
    DP = [[0 for j in range(lens)] for i in range(lens - 1)]
    maxlength = 0
    for i in reversed(range(lens - 1)):
        for j in reversed(range(i + 1, lens)):
            if sdict[i] == sdict[j]:
                if j == lens - 1: DP[i][j] = 1
                else: DP[i][j] = DP[i+1][j+1] + 1
                maxlength = max(maxlength, min(DP[i][j], j - i))

    print(maxlength)
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys

def solve():
    N = int(input())
    S = input()
    lens = len(S)
    alp = ["a", "b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u",\
        "v","w","x","y","z"]
    
    DP = [[0 for j in range(lens)] for i in range(lens)]
    DP[lens - 2][lens - 1] = (1 if S[lens-2] == S[lens - 1] else 0)
    for i in reversed(range(lens - 1)):
        for j in reversed(range(i + 1, lens)):
            if S[i] == S[j]:
                if j == lens - 1: DP[i][j] = 1
                else: DP[i][j] = DP[i+1][j+1] + 1

    maxlength = 0
    for i in range(lens):
        for j in range(i+1, lens):
            maxlength = max(maxlength, min(DP[i][j], j - i))

    print(maxlength)
    return 0

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

from itertools import accumulate
from functools import reduce

n,k = map(int, input().split())
a = list(map(int, input().split()))
acc = [0] + list(accumulate(a))
be = set()
# print(acc)
for i in range(n):
    for j in range(i+1,n+1):
        if acc[j] - acc[i] not in be:
            be.add(acc[j] - acc[i])
# print(be)
be = list(be)
mx = max(be)
# print(bin(mx))
bin_dic = {i:[] for i in range(len(str(bin(mx)))-2)}
# print(binary)
for b in be:
    for i,c in enumerate(str(bin(b))[-1:1:-1]):
        if c == '1':
            bin_dic[i].append(b)
mx_bin = 0
for i in bin_dic.keys():
    if k <= len(bin_dic[i]) and mx_bin < i:
        mx_bin = i
cands = set(bin_dic[mx_bin])
for i in range(mx_bin)[::-1]:
    tmp = set(bin_dic[i]) & cands
    if len(tmp) == k:
        cands = tmp
        break
    elif len(tmp) > k:
        cands = tmp
print(reduce(lambda x,y:x&y, cands))
      

### FIXED CODE ###

from itertools import accumulate
from functools import reduce

n,k = map(int, input().split())
a = list(map(int, input().split()))
acc = [0] + list(accumulate(a))
be = set()
# print(acc)
for i in range(n):
    for j in range(i+1,n+1):
        if acc[j] - acc[i] not in be:
            be.add(acc[j] - acc[i])
# print(be)
be = list(be)
mx = max(be)
# print(bin(mx))
bin_dic = {i:[] for i in range(len(str(bin(mx)))-2)}
# print(binary)
for b in be:
    for i,c in enumerate(str(bin(b))[-1:1:-1]):
        if c == '1':
            bin_dic[i].append(b)
mx_bin = 0
for i in bin_dic.keys():
    if k <= len(bin_dic[i]) and mx_bin < i:
        mx_bin = i
cands = set(bin_dic[mx_bin])
for i in range(mx_bin)[::-1]:
    tmp = set(bin_dic[i]) & cands
    if len(tmp) == k:
        cands = tmp
        break
    elif len(tmp) > k:
        cands = tmp
print(reduce(lambda x,y:x&y, cands))
### BUGGY CODE ###

#import sys

#input = sys.stdin.readline

#import heapq

def main():
#    h,w,a,b = map(int, input().split())
    n=int(input())
    a = list(map(int,input().split()))
    b=[]
    for i in range(n):
        b.append([i+1,a[i]])
    b=sorted(b,key=lambda x: x[1])
    c=""
 #   print(b)
    for i in range(n):
        c=c + str(b[i][0]) + " "
    c.rstrip()
    print(c)

#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

### FIXED CODE ###

#import sys

#input = sys.stdin.readline

import heapq

def main():
#    h,w,a,b = map(int, input().split())
    n=int(input())
    a = list(map(int,input().split()))
    b=[]
    for i in range(n):
        b.append([a[i],i+1])
#    print(b)
#    heapq.heapify(b)
#    print(heapq.heappop(b))
#    print(b)
    b=sorted(b,key=lambda x: x[0])
    for i in range(n):
        print(b[i][1], end=" ")


#    for i in range(h):
#            print(aaa)

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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  l=[I() for _ in range(m)]

  dp=[0 for _ in range(n+1)]
  dp[0]=1
  for i in range(n):
    for j in range(1,3):
      if i+j<=n and i not in l:
        dp[i+j]+=dp[i]

  # print(dp)
  return dp[n]%mod

# main()
print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  dp=[0]*100010

  n,m=LI()

  dp[0]=1
  dp[1]=1

  for _ in range(m):
    dp[I()]=-1

  for i in range(2,n+1):
    if dp[i]==-1:
      continue

    if dp[i-2]!=-1:
      dp[i]+=dp[i-2]
    if dp[i-1]!=-1:
      dp[i]+=dp[i-1]

    dp[i]%=mod

  return dp[n]%mod

print(main())
### BUGGY CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
A = l()
A += A
num = sum(A)//4
ans = []
for i in range(N):
    num2 = 0
    for j in range((N-1)//2):
        num2 += A[i+1+2*j]
    ans.append((num-num2)*2)
print(*ans)

### FIXED CODE ###

def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))

N = i()
A = l()
num = sum(A)//2
A += A
ans = []
for i in range(1):
    num2 = 0
    for j in range(0,N,2):
        num2 += A[i+j]
    ans.append(abs((num-num2))*2)
    r = abs((num-num2))*2
for i in range(1,N):
    r = A[i-1]*2-r
    ans.append(r)
print(*ans)
### BUGGY CODE ###

cnt=0
S=str(input())
m=[0]*len(S)
for i in range(len(S)):
    m[i]=int(S[i:])%2019 
    if m[i]==0:
        cnt+=1
for i in range(len(S)):
    for j in range(i+1,len(S)):
        if m[i]==m[j]:
            cnt+=1 
print(cnt)


### FIXED CODE ###

S=input()
mc=[0]*2019

tg=0
digit=1
for s in S[::-1]:
    tg+=int(s)*digit
    mc[tg%2019]+=1
    digit=digit*10%2019

ans=sum(m*(m-1)//2 for m in mc)
print(ans+mc[0])
### BUGGY CODE ###


def cal_cnt(num):
  cnt = 0
  for bit in format(num, 'b'):
    if bit == '1':
      cnt += 1

  return cnt


def main():
  n = int(input())
  src = input()
  base = int(src, 2)
  base_cnt = 0
  for bit in src:
    if bit == '1':
      base_cnt += 1

  memo = tuple(map(cal_cnt, range(n)))

  dp = [None] * n
  dp[0] = 0

  def popcount(num, cnt):
    if num < n and dp[num] is not None:
      return dp[num]

    nxt = num % cnt
    res = 1 + popcount(nxt, memo[nxt])
    if num < n:
      dp[num] = res

    return res

  for i in range(n - 1, -1, -1):
    num, cnt = (base + 2 ** i, base_cnt + 1) if src[n - i - 1] == '0' else (base - 2 ** i, base_cnt -1)
    print(popcount(num, cnt))


main()


### FIXED CODE ###


def f(n):
  cnt = 0
  while n:
      cnt += 1
      n = n % bin(n).count('1')

  return cnt

def main():
  n = int(input())
  src = input()
  base = int(src, 2)
  base_cnt = src.count('1')

  basep = base % (base_cnt + 1)
  basem = base % (base_cnt - 1) if base_cnt > 1 else 0

  for i, s in enumerate(src):
    i = n - 1 - i
    num = None

    if s == '0':
      mod = base_cnt + 1
      num = (basep + pow(2, i, mod)) % mod
    elif base_cnt > 1:
      mod = base_cnt - 1
      num = (basem - pow(2, i, mod)) % mod
    else:
      print(0)
      continue

    print(1 + f(num))


main()
### BUGGY CODE ###

def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


def get_xor(a, b):
  bin_a = format(a, 'b')
  bin_b = format(b, 'b')

  digit = max(len(bin_a), len(bin_b))

  # 2進数のケタ数を揃える
  bin_a = bin_a.zfill(digit)
  bin_b = bin_b.zfill(digit)
  s = ''

  for i in range(len(bin_a)):
    if bin_a[i] == '0' and bin_b[i] == '1':
      s += '1'
    elif bin_a[i] == '1' and bin_b[i] == '0':
      s += '1'
    else:
      s += '0'

  # 10進数に戻す
  return int(s, 2)


def can_put_on_cap(n):
  global caps

  if n in caps.keys():
    if caps[n] > 0:
      caps[n] -= 1
      return True


# A - XOR Circle
import sys
input = sys.stdin.readline
import copy

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

# 帽子の情報をdictに入れる
dic = get_caps(a)

for i in range(N):
  for j in range(i+1, N):
    caps = copy.deepcopy(dic)
    caps[a[i]] -= 1
    caps[a[j]] -= 1
        
    left = a[i]
    mid = a[j]
    count = 2
    
    for k in range(N-2):
      right = get_xor(left, mid)
    
      if can_put_on_cap(right):
        left = mid
        mid = right
        count += 1
      else:
        break
    
    if count == N:
      if left ^ a[i] == right:
            print('Yes')
            exit()

print('No')

### FIXED CODE ###

def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


def is_match(caps):
  global N

  if 0 in caps.keys():
    if caps[0] == N:
      return True
  
  if N % 3 == 0:
    if 0 in caps.keys() and len(caps) == 2:
      if caps[0] == N//3:
        return True
    elif len(caps) == 3:
      x, y, z = caps.keys()
    
      if x ^ y ^ z == 0:
        if caps[x] == caps[y] == caps[z] == N//3:
          return True


# A - XOR Circle
N = int(input())
a = list(map(int, input().split()))

# 帽子の情報をdictに入れる
caps = get_caps(a)

if is_match(caps):
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

n = int(input())
d = list(map(lambda x: int(x), input().split()))

res = 0


def is_triangle(i, j, k):
    return i < j + k and j < i + k and k < i + j


for i in range(n):
    for j in range(n):
        for k in range(n):
            if i != j and j != k and i != k and is_triangle(d[i],d[j],d[k]):
                res += 1

print(res // 6)

### FIXED CODE ###

n = int(input())
d = list(map(lambda x: int(x), input().split()))
d.sort()

res = 0

for i in range(n-2):
    k = i + 2
    for j in range(i+1, n-1):
        while k < n and d[i] + d[j] > d[k]:
            k += 1
        if k > j:
            res += k - j - 1

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

import sys
from collections import deque
input = sys.stdin.readline
n = int(input())
m = [[-1 for _ in range(n)] for _ in range(n)]
np = [deque([]) for _ in range(n)]
for _ in range(n-1):
    a, b, c = [int(x) for x in input().strip().split()]
    m[a-1][b-1] = c
    m[b-1][a-1] = c
    np[a-1].append(b)
    np[b-1].append(a)

q, k = [int(x) for x in input().strip().split()]
master = [-1 for _ in range(n)]
master[k-1] = 0

def dfs(cur, pre, master):
    #print('cur = {}, pre = {}'.format(cur, pre))
    for p in np[cur-1]:
        if p == pre:
            continue
        master[p-1] = master[cur-1] + m[cur-1][p-1]
        dfs(p, cur, master)

dfs(k, -1, master)

for _ in range(q):
    x, y = [int(x) for x in input().strip().split()]
    print(master[x-1] + master[y-1])

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n = int(input())
m = {}
np = [deque([]) for _ in range(n)]
for _ in range(n-1):
    a, b, c = [int(x) for x in input().strip().split()]
    m[(a, b)] = c
    m[(b, a)] = c
    np[a-1].append(b)
    np[b-1].append(a)

q, k = [int(x) for x in input().strip().split()]
master = [-1 for _ in range(n)]
master[k-1] = 0

def dfs(cur, pre, master):
    #print('cur = {}, pre = {}'.format(cur, pre))
    for p in np[cur-1]:
        if p == pre:
            continue
        master[p-1] = master[cur-1] + m[(cur, p)]
        dfs(p, cur, master)

dfs(k, -1, master)

for _ in range(q):
    x, y = [int(x) for x in input().strip().split()]
    print(master[x-1] + master[y-1])
### BUGGY CODE ###

# import itertools


def main():
    n = int(input())
    s = input()
    # comb = itertools.combinations(range(n), 3)
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            for c in range(b+1, n):
                if b - a == c - b:
                    continue
                if len(set((s[a], s[b], s[c]))) == 3:
                    ans += 1
    return ans


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

def main():
    n = int(input())
    s = input()
    # Positions for each character.
    r = set()
    g = set()
    r_add = r.add
    g_add = g.add
    for ind, c in enumerate(s):
        if c == 'R':
            r_add(ind)
        elif c == 'G':
            g_add(ind)
    b = set(range(n)) - r - g

    ans = 0
    for i in r:
        for j in g:
            p, q = min(i, j), max(i, j)
            if (q - p) % 2 == 0 and (p + q) // 2 in b:
                ans -= 1
            if (q + (q - p)) in b:
                ans -= 1
            if (p - (q - p)) in b:
                ans -= 1
            ans += len(b)
    return ans


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

import copy

N = int(input())

A = [int(input()) for _ in range(N)]

for i in range(N):
    B = copy.deepcopy(A)
    B.pop(i)
    print(max(B))


### FIXED CODE ###

import copy

N = int(input())

A = [int(input()) for _ in range(N)]
B = sorted(A)
max_1 = B[-1]
max_2 = B[-2]

for i in range(N):
    if(A[i]==max_1):
        print(max_2)
    else:
        print(max_1)