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

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

n = INT()
a = sorted(LIST())

m = 1000
primes = set(range(2, m+1))
for i in range(2, int(m**0.5+1)):
    primes.difference_update(range(i*2, m+1, i))
primes=list(primes)

for i in range(n):
    for x in primes:
        while a[i] % pow(x,2) == 0:
            a[i] //= x

k = 1
flag = 1
for i in range(1, n):
    k *= a[i-1]
    if gcd(k, a[i]) > 1:
        flag = 0
        break

if flag == 1:
    print("pairwise coprime")
    exit()
else:
    g = a[0]
    for i in range(1, n):
        g = gcd(g, a[i])
    if g == 1:
        print("setwise coprime")
    else:
        print("not coprime")

### FIXED CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

n = INT()
a = LIST()
m = max(a)

primes = [0]*(m+1)
primes[1] = 1
for i in range(2, m+1):
    if primes[i] == 0:
        for j in range(1, m//i+1):
            primes[i*j] = i

count = [0]*(m+1)
for x in a:
    y = x
    while primes[y] != y:
        count[primes[y]] += 1
        p = primes[y]
        while y % p == 0:
            y //= p
    if primes[y] >= 2:
        count[primes[y]] += 1

if max(count) <= 1:
    print("pairwise coprime")
else:
    g = 0
    for x in a:
        g = gcd(g, x)
    if g == 1:
        print("setwise coprime")
    else:
        print("not coprime")
### BUGGY CODE ###

import math
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

def lcm(a, b):
    return (a * b) // math.gcd(a, b)

a_lcm = 1
for i in range(n):
    a_lcm = a_lcm * a[i] // math.gcd(a_lcm, a[i])

b_sum = 0
for i in range(n):
    b_sum = (b_sum + (a_lcm // a[i])) % mod

print(b_sum)


### FIXED CODE ###

import math
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

def lcm(a, b):
    return (a * b) // math.gcd(a, b)

a_lcm = 1
for i in range(n):
    a_lcm = lcm(a_lcm, a[i])

b_sum = 0
for ai in a:
    b_sum += a_lcm // ai

print(b_sum%mod)
### BUGGY CODE ###

S = input()
Q = int(input())
for i in range(Q):
    list = input().split(' ')
    if list[0] == '1':
        S = S[::-1]
        continue
    elif list[1] == '1':
        S = list[2]+S
        continue
    elif list[1] == '2':
        S = S+list[2]
        continue
print(S)

### FIXED CODE ###

from collections import deque
S = deque()
S.extend(input())
Q = int(input())
reverse = 0
for i in range(Q):
    list = input().split(' ')
    if list[0] == '1':
        reverse += 1
    elif list[1] == '1':
        if reverse % 2 == 1:
            S.append(list[2])
        else:
            S.appendleft(list[2])
    elif list[1] == '2':
        if reverse % 2 == 1:
            S.appendleft(list[2])
        else:
            S.append(list[2])
if reverse % 2 == 1:
    S.reverse()
ans = ''.join(S)
print(ans)
### BUGGY CODE ###

from bisect import bisect_left, bisect_right
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()


def check(x):
    # k番目の数がx以下であるか
    # x以下の数字がk個以上あるか
    cnt = 0
    for i in range(n):
        if a[i] > 0:
            idx = bisect_right(a, x // a[i])
            cnt += max(idx - i - 1, 0)
        elif a[i] < 0:
            idx = bisect_left(a, -(x // abs(a[i])))
            # cnt += n - idx
            cnt += n - max(idx, i + 1)
        else:
            # a[i] == 0
            if x >= 0:
                cnt += n - i - 1

        if cnt >= k:
            return True
    # print('check', x, cnt)
    return cnt >= k


lb = -10**18  # False
ub = +10**18  # True
while ub - lb > 1:
    mid = (ub + lb) // 2
    # print(lb, ub)
    if check(mid):
        ub = mid
    else:
        lb = mid

print(ub)


### FIXED CODE ###

from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline

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

a_minus = a_zero = a_plus = 0
for i in range(n):
    if a[i] > 0:
        a_plus += 1
    elif a[i] == 0:
        a_zero += 1
    else:
        a_minus += 1

aa_minus = a_minus * a_plus
aa_zero = a_zero * (n - a_zero) + a_zero * (a_zero - 1) // 2


def check_minus(x):
    # k番目の数がx(<0)以下であるか
    # x以下の数字がk個以上あるか
    cnt = 0
    j = a_minus + a_zero
    for i in range(a_minus):
        # a[i] < 0
        while j < n and a[i] * a[j] > x:
            j += 1
        cnt += n - j

    return cnt >= k


def check_plus(x):
    # k番目の数がx(>0)以下であるか
    # x以下の数字がk個以上あるか

    def func(b, m):
        # 昇順ソート済みの数列b (長さm)
        # 掛け算してx以下となる数を求める
        c = 0
        j = m - 1
        for i in range(m):
            while j > 0 and b[i] * b[j] > x:
                j -= 1
            c += max(j - i, 0)
        return c

    cnt = aa_minus + aa_zero
    cnt += func(a[-a_plus:], a_plus)
    cnt += func(list(reversed(a[:a_minus])), a_minus)
    return cnt >= k


if k <= aa_minus:
    # k番目の数は負の数
    lb = a[0] * a[-1] - 1  # False
    ub = 0  # True
    while ub - lb > 1:
        mid = (ub + lb) // 2
        if check_minus(mid):
            ub = mid
        else:
            lb = mid

    ans = ub
elif k <= aa_minus + aa_zero:
    # k番目の数は0
    ans = 0
else:
    # k番目の数はプラス
    lb = 0  # False
    ub = max(a[0]**2, a[-1]**2) + 1  # True
    while ub - lb > 1:
        mid = (ub + lb) // 2
        if check_plus(mid):
            ub = mid
        else:
            lb = mid

    ans = ub

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

import numpy as np

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    ans = 0
    if sum(a) >= k:
        for i in range(n):
            if k <= a[i]:
                continue
            dp = np.zeros((k+1), dtype=np.bool)
            dp[0] = True
            for j in range(n):
                if k <= a[j] or j == i:
                    continue
                dp[a[j]:] |= dp[:-a[j]]
            f = False
            for j in range(k-a[i], k):
                f |= dp[j]
            if not f:
                ans += 1
    else:
        ans = n
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy as np

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    if sum(a) >= k:
        a.sort()
        L, R = -1, n-1
        while L+1 < R:
            P = (L+R+1)//2
            if k <= a[P]:
                R = P
                continue
            dp = np.zeros((k+1), dtype=np.bool)
            dp[0] = True
            for j in range(n):
                if k <= a[j] or j == P:
                    continue
                dp[a[j]:] |= dp[:-a[j]]
            f = False
            for j in range(k-a[P], k):
                f |= dp[j]
            if f:
                R = P
            else:
                L = P
        print(R)
    else:
        print(n)

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

import sys


def prime_list(n):
    limit = int(n ** 0.5) + 1
    lis = range(1, n + 1, 2)
    lis[0] = 2
    while True:
        if len(lis) == 0:
            break
        p = lis.pop(0)
        yield p
        if p <= limit:
            lis = [x for x in lis if x % p != 0]


def primes_number(n):
    primes = []
    for p in prime_list(n):
       primes.append(p)
    return len(primes)


#input_file = open(sys.argv[1], "r")

#for line in input_file:
for line in sys.stdin:
    n = int(line)
    print primes_number(n)

### FIXED CODE ###


import sys


def prime_list(n):
    limit = int(n ** 0.5) + 1
    lis = range(1, n + 1, 2)
    lis[0] = 2
    while True:
        if len(lis) == 0:
            break
        p = lis.pop(0)
        yield p
        if p <= limit:
            lis = [x for x in lis if x % p != 0]


def primes_number(n):
    primes = []
    for p in prime_list(n):
       primes.append(p)
    return primes


ns = map(int, sys.stdin.readlines())
max_n = max(ns)

primes = primes_number(max_n)


for n in ns:
    p = len(filter(lambda x: x <= n, primes))
    print p
### BUGGY CODE ###

s=input()
b=0
m=len(s)
c=[0 for i in range(2019)]
c[0]=c[0]+1
a=""
e=0
for i in range(m-1,-1,-1):
    a=str(a)
    a=int(s[i]+a)
    d=a%2019
    c[d]=c[d]+1
for i in c:
    if i<=1:
        continue
    e+=i*(i-1)//2
print(e)


### FIXED CODE ###

s=input()
b=0
m=len(s)
c=[0 for i in range(2019)]
c[0]=c[0]+1
a=""
e=0
f=1
s= ''.join(list(reversed(s)))
for i in s:
    e+=int(i)*f
    g=e%2019
    c[g]+=1
    f*=10
    f%=2019
e = sum(i * (i - 1) // 2 for i in c)
print(e)
### BUGGY CODE ###

from itertools import combinations_with_replacement
def f(n):
    ret = 0
    for x, y, z in combinations_with_replacement(range(1, n), 3):
        if x**2+y**2+z**2+x*y+y*z+z*x==n:
            if x==y==z:
                ret += 1
            elif x==y or y==z or z==x:
                ret += 3
            else:
                ret += 6
    return ret
N = int(input())
for n in range(1, N+1):
    print(f(n))

### FIXED CODE ###

from itertools import combinations_with_replacement
def f(N):
    global table
    for x, y, z in combinations_with_replacement(range(1, 100), 3):
        n = x**2+y**2+z**2+x*y+y*z+z*x
        if n>N:
            continue
        if x==y==z:
            table[n] += 1
        elif x==y or y==z or z==x:
            table[n] += 3
        else:
            table[n] += 6
N = int(input())
table = [0 for _ in range(N+1)]
f(N)
for n in range(1, N+1):
    print(table[n])
### BUGGY CODE ###

#from scipy.special import comb

counter = [0]*2019
counter[0] = 1 # 0 = 0 (mod 2019)

S = input()
for i in range(1,len(S)+1):
    tmp = int(S[-i:])
    #print(tmp%2019)
    counter[tmp%2019] += 1

ans = 0
for i in range(2019):
    if counter[i] >= 2:
        #ans += comb(counter[i], 2, exact=True)
        ans += counter[i]*(counter[i]-1)//2
print(ans)
    
    


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Sep  6 23:39:24 2020

@author: liang
"""
#from scipy.special import comb

counter = [0]*2019
counter[0] = 1 # 0 = 0 (mod 2019)

S = input()
tmp = 0
"""
#大きい数を一気に掛けない
for i in range(1,len(S)+1):
    tmp += int(S[-i])*10**(i-1)    #スライスの方が早い（けど、漸化式的に累積和を出せ）
    #print(tmp%2019)
    tmp %= 2019                    #大きい数を割るな
    counter[tmp%2019] += 1

ans = 0
for i in range(2019):
    if counter[i] >= 2:
        #ans += comb(counter[i], 2, exact=True)
        ans += counter[i]*(counter[i]-1)//2
print(ans)
"""
MOD = 2019
#reversed(s) ?
t = 1
for i in range(1,len(S)+1):
    tmp += int(S[-i])*t
    #print("A", tmp)
    tmp %= MOD 
    t *= 10
    #print("B", tmp)
    t %= MOD
    #print(tmp)
    counter[tmp] += 1
    
print(sum(i*(i-1)//2 for i in counter))
### BUGGY CODE ###


s = input()
n = int(input())

flag = 0
for i in range(n):
    Q = input()
    if int(Q[0]) == 2:
        F = int(Q[2])
        C = Q[4]
        #print(F, C)
        if (F + flag) % 2 == 1:
            s = C + s
        else:
            s = s + C
    else:
        flag = (flag + 1) % 2 

if flag == 1:
    s = s[::-1]
print(s)


### FIXED CODE ###


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

flag = 0
s1 = []
s2 = s
for i in range(n):
    Q = input()
    if Q[0] == "2":
        if Q[2] == "1":
            if flag == 1:
                s2.append(Q[4])
            else:
                s1.append(Q[4])
        else:
            if flag == 0:
                s2.append(Q[4])
            else:
                s1.append(Q[4])
    else:
        flag ^= 1
s2 = s1[::-1] + s2
print("".join(s2) if flag == 0 else "".join(s2[::-1]))
### BUGGY CODE ###

l, r = list(map(int, input().split()))
MOD = 2019
ans = 2018
for i in range(l,r):
    for j in range(i+1, r+1):
        ans = min(ans, (i%MOD*j%MOD)%MOD )
        
print(ans)

### FIXED CODE ###

l, r = list(map(int, input().split()))
MOD = 2019
diff = r - l
ans = 0
if diff < 2019:
    l = l%MOD
    r = l + diff
    ans = 2018
    for i in range(l,r):
        for j in range(i+1, r+1):
            ans = min(ans, (i%MOD*j%MOD)%MOD )
      
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 22:10:01 2019

@author: Yamazaki Kenichi
"""
import bisect
import numpy as np

A,B,Q = map(int,input().split())
s = np.array([int(input()) for i in range(A)])
t = np.array([int(input()) for i in range(B)])
x = np.array([int(input()) for i in range(Q)])

def lr(s,c,A):
#    si = bisect.bisect(s,c)
    si = s.searchsorted(c)
    if si == A:
        return [c-s[si-1], 10**11]
    elif si == 0:
        return [10**11, s[0]-c]
    else:
        return [c-s[si-1], s[si]-c]
for c in x:
    ans = 0
    slr = lr(s,c,A)
    tlr = lr(t,c,B)
    ans = min(max(slr[0],tlr[0]),
              max(slr[1],tlr[1]),
              slr[0]*2+ tlr[1],
              slr[0]+ tlr[1]*2,
              slr[1]*2 + tlr[0],
              slr[1]+ tlr[0]*2
              )
    print(ans)
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 22:10:01 2019

@author: Yamazaki Kenichi
"""
import numpy as np
import bisect

A,B,Q = map(int,input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
x = [int(input()) for i in range(Q)]

def lr(s,c,A):
    si = bisect.bisect(s,c)
    if si == A:
        return [c-s[si-1], 10**11]
    elif si == 0:
        return [10**11, s[0]-c]
    else:
        return [c-s[si-1], s[si]-c]
for c in x:
    ans = 0
    slr = lr(s,c,A)
    tlr = lr(t,c,B)
    ans = min(max(slr[0],tlr[0]),
              max(slr[1],tlr[1]),
              slr[0]*2+ tlr[1],
              slr[0]+ tlr[1]*2,
              slr[1]*2 + tlr[0],
              slr[1]+ tlr[0]*2
              )
    print(ans)
### BUGGY CODE ###

import math

n = int(input())
arr = [0] * n

for x in range(1,1001):
    for y in range(1,1001):
        for z in range(1,1001):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans <= n:
                arr[ans - 1] += 1

for i in range(n):
    print(arr[i])

### FIXED CODE ###

#!/usr/bin/env python3
import math

n = int(input())
arr = [0] * n

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans <= n:
                arr[ans - 1] += 1

for i in range(n):
    print(arr[i])
### BUGGY CODE ###

import sys

def bubble_sort(arr):
    counter = 0
    change = True
    for i in range(len(arr)):
        for j in range(len(arr) - 1, i, -1):
            if arr[j] < arr[j - 1]:
                arr[j], arr[j - 1] = arr[j - 1], arr[j]
                counter += 1
        if change == 0: break
    return arr, counter


def solve():
    input = sys.stdin.readline
    S = list(input().replace("B", "2").replace("W", "1"))[:-1]
    S, counter = bubble_sort(S)

    print(counter)


solve()


### FIXED CODE ###

import sys


def solve():
    input = sys.stdin.readline
    S = list(input().replace("B", "2").replace("W", "1"))[:-1]
    N = len(S)
    ans = N * (N - 1) // 2
    data = [0] * (N + 1)

    def add(k, v):
        while k <= N:
            data[k] += v
            k += k & -k

    def get(k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    for a in map({a: i + 1 for i, a in enumerate(sorted(S))}.__getitem__, S):
        ans -= get(a)
        add(a, 1)

    print(ans)


solve()
### BUGGY CODE ###

from bisect import bisect_left, bisect_right
N = int(input())
L = [int(c) for c in input().split()]
L.sort()
ans = 0
for i in range(N):
  for j in range(i+1, N):
    x = L[i]+L[j]
    ind = bisect_left(L, x)
    IND = bisect_right(L,x)
    ans += ind-j-1 if ind-j>0 else 0
#    print(x,ind)

print(ans)

### FIXED CODE ###

from bisect import bisect_left
N = int(input())
L = [int(c) for c in input().split()]
L.sort()
ans = 0
for i in range(N):
  for j in range(i+1, N):
    x = L[i]+L[j]
    ind = bisect_left(L, x)
    ans += ind-j-1
#    print(x,ind)

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

S=raw_input()
L=len(S)

M=10**9+7

dp=[ [ 0 for i in range(4) ] for k in range(L+1) ]
all=1

abc=0
ab=0
a=0

for i in range(L):
	if S[i]=="A":
		a=( a+all ) %M
	if S[i]=="B":
		ab=( ab+a )%M
	if S[i]=="C":
		abc=( abc+ab )%M

	if S[i]=="?":
		abc=( abc*3+ab )%M
		ab=( ab*3+a)%M
		a=( a*3+all )%M
		all*=3

print abc%M


### FIXED CODE ###

S=raw_input()

M=10**9+7

all=1
abc=0
ab=0
a=0

for x in S:
	if x=="A":
		a+=all
	if x=="B":
		ab+=a
	if x=="C":
		abc+=ab

	if x=="?":
		abc=abc*3+ab
		ab=ab*3+a
		a= a*3+all
		all*=3

	abc%=M
	ab%=M
	a%=M
	all%=M


print abc%M
### BUGGY CODE ###

S = input()
Q = int(input())

n = S
# r = S
# for i in range(Q):
#     op = input().split()
#     if len(op) == 1:
#         n, r = r, n
#     elif op[1] == "1":
#         n = op[2] + n
#         r = r + op[2]
#     else:
#         n = n + op[2]
#         r = op[2] + r
# print(n)

mode = 0
for i in range(Q):
    op = input().split()
    if len(op) == 1:
        mode += 1
        mode %= 2
    elif int(op[1]) + mode == 2:
        n = n + op[2]
    else:
        n = op[2] + n
if mode == 0:
    print(n)
else:
    print(n[::-1])

### FIXED CODE ###

from collections import deque
S = input()
Q = int(input())

n = S
mode = 0
operations = []
deq = deque(n)
for i in range(Q):
    operations.append(input().split())
for op in operations:
    if op[0] == "1":
        mode += 1
        mode %= 2
    elif int(op[1]) + mode == 2:
        deq.append(op[2])
    else:
        deq.appendleft(op[2])
if mode == 0:
    print("".join(deq))
else:
    print("".join(reversed(deq)))
### BUGGY CODE ###

def main():
    t = input()
    if t == "1":
        print(1)
        exit(0)
    li = [int(v) for v in input().split(' ')]
    s_li = sorted(li)
    count = 0
    c1 = 0
    for v in range(s_li[0] - 1, s_li[-1] + 1):
        t_c = 0
        c1 = s_li.count(v - 1)
        c2 = s_li.count(v)
        c3 = s_li.count(v + 1)

        t_c = c1 + c2 + c3
        if t_c > count:
            count = t_c
        if c1 != 0:
            s_li = s_li[s_li.index(v - 1):]
        if count > len(s_li):
            break
    print(count)



if __name__ == '__main__':
    main()

### FIXED CODE ###

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

s = input()
ans = 0
for j in range(3, len(s)):
    for i in range(len(s)-j):
        if int(s[i:i+j + 1]) %2019 ==0:
            ans += 1
print(ans)

### FIXED CODE ###

numbers = [0]*2019
numbers[0] = 1
s = input()
t = 0
mod = 2019
u = 1
for i in range(1, len(s) + 1):
    t = (t + int(s[-i]) * u )% mod
    numbers[t] += 1
    u = 10*u%mod
ans = 0
for n in numbers:
    ans += n*(n-1)/2
print(int(ans))
### BUGGY CODE ###

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

for i in range(q):
  query = input()
  if query == '1':
    s = s[::-1]
  else:
    query = query.split()
    f, c = int(query[1]), query[2]
    if f == 1:
      s = c + s
    else:
      s = s + c
print(s)

### FIXED CODE ###


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


is_reverse = False
pre_s = ""
suf_s = ""

for i in range(q):
  query = input()
  if query == '1':
    is_reverse = not is_reverse
  else:
    query = query.split()
    f, c = int(query[1]), query[2]
    if f == 1:
      if is_reverse:
        suf_s = suf_s + c
      else:
        pre_s = c + pre_s
    else:
      if is_reverse:
        pre_s = c + pre_s
      else:
        suf_s = suf_s + c

if is_reverse:
  print(suf_s[::-1] + s[::-1] + pre_s[::-1])
else:
  print(pre_s + s + suf_s)
### BUGGY CODE ###

import numpy as np
n,k = map(int, input().split())
n = n + 1
mod = 10**9+7
bag = []
ans = 0
for i in range(n):
	bag.append(i)
reverse =  bag[::-1]
for j in range(k, n+1):
	max = np.sum(reverse[:j])
	min = np.sum(bag[:j])
	ans = max-min+1 + ans
ans = ans % mod
print(ans)

### FIXED CODE ###

n,k = map(int, input().split())
AR = n + 1
mod = 10**9+7
ans = 0

def calc_ans(AR,i):
	max = AR*(AR-1)/2 - (AR-i)*(AR-i-1)/2
	min = i*(i-1)/2
	return max - min +1

for i in range(k, AR+1):
	ans += calc_ans(AR,i)

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

# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
S=sys.stdin.readline().strip()

def judge(n):   #n:文字列の長さで条件を満たせるかをジャッジする
    for i in range(N):
        if N<i+n:  continue
        s=S[i:i+n]
        if s in S[i+n:]:
            return True
    else:
        return False

h=N
l=0
while h-l!=1:
    m=(h+l)/2
    if judge(m):    #条件を見たしていれば、下限lをmの位置まで引き上げる
        l=m
    else:    #条件を見たしていなければ、上限hをmの位置まで引き下げる
        h=m
print l


### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import defaultdict
N=input()
s=raw_input()

str="abcdefghijklmnopqrstuvwxyz"
D={}
for i,str in enumerate(str):
	D[str]=i+1

base=27
mod=2**61-1
hash=[]

for i,x in enumerate(s):
	if i==0: hash.append(D[x]%mod)
	else: hash.append( (hash[-1]*base+D[x])%mod )

def get(l,r):
	if l==0: return hash[r-1]%mod
	else: return ( hash[r-1]-hash[l-1]*pow(base,(r-l),mod) )%mod

# 長さmを固定し、区間 [i, i + m) のハッシュ値を求めて、長さmの共通文字列があるかを判定
def check(m):
	C={}
	for i in range(N):
		if i+m<=N:
			hash_value=get(i,i+m)
			if hash_value in C:
				if m<=i-C[hash_value]:
					return True
			else:
				C[hash_value]=i
	else:
		return False

l=0
h=N

while 1<(h-l):
	m=(l+h)/2
	if check(m):
		l=m
	else:
		h=m

print l
### BUGGY CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
dp = [0] * (N+10)
dp[2] = abs(A[1] - A[0])
for i in range(2,N):
    res = []
    if K > i:
        kk = i+1
    else:
        kk = K + 1
    for j in range(1,kk):
        res.append(abs(A[i] - A[i-j])+dp[i-j+1])
    dp[i+1] = min(res)
 
print(dp[N])

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    dp = [0] * (N+10)
    dp[2] = abs(A[1] - A[0])
    for i in range(2,N):
        res = []
        if K > i:
            kk = i+1
        else:
            kk = K + 1
        for j in range(1,kk):
            res.append(abs(A[i] - A[i-j])+dp[i-j+1])
        dp[i+1] = min(res)
    
    print(dp[N])
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    b = a.pop(0)
    #print(a)
    print(max(a))
    a.append(b)
    #rint(a)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
maxi = max(a)
s = sorted(a,reverse=True)

for i in range(n):
    if a[i] != maxi:
        print(maxi)
    else:
        print(s[1])