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

import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
for i in A:
    ans += lcm // i
    ans %= mod
print(ans) 

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
for i in A:
    ans += lcm // i
print(ans % mod)
### BUGGY CODE ###

n = int(input())

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

from fractions import gcd

m = max(A)
for i in A:
    for j in A:
        m = min(m, gcd(i, j))
print(m)

### FIXED CODE ###

n = int(input())

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

t = max(A)

from fractions import gcd

for i in A:
    t = gcd(t, i)
print(t)
### BUGGY CODE ###

x,y,z,q=map(int,input().split())
*a,=map(int,input().split())
*b,=map(int,input().split())
*c,=map(int,input().split())
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
 
class bisect:
  def bisect(self,l,r):
    cnt=(l+r)//2
    if cnt==l:
      return l-1+self.judge(l)
    if self.judge(cnt):
      return self.bisect(cnt+1,r)
    else:
      return self.bisect(l,cnt)
  def judge(self,thr):
    m=0
    for i in a:
      for j in b:
        for k in c:
          if i+j+k>thr:
            m+=1
            if m>=q:
              return True
    return False

def make(thr):
  m=0
  l=[]
  for i in a:
    for j in b:
      for k in c:
        n=i+j+k
        if n>thr:
          m+=1
          l+=[n]
          if m>=q:
            l.sort(reverse=True)
            return l

s=bisect()
thr=s.bisect(0,a[0]+b[0]+c[0]+1)
ans=make(thr)
for w in ans:
  print(w)

### FIXED CODE ###

x,y,z,q=map(int,input().split())
a=sorted(map(int,input().split()),reverse=True)
b=sorted(map(int,input().split()),reverse=True)
c=sorted(map(int,input().split()),reverse=True)
 
def bisect(l,r):
  cnt=(l+r)//2
  if cnt==l:
    return l-1+judge(l)
  if judge(cnt):
    return bisect(cnt+1,r)
  else:
    return bisect(l,cnt)
def judge(thr):
  m=0
  for i in range(x):
    for j in range(y):
      if i*j>q:
        break
      for k in range(z):
        if i*j*k>q or a[i]+b[j]+c[k]<thr:
          break
        m+=1
        if m>=q:
          return True
  return False
def make(thr):
  m=0
  l=[]
  for i in a:
    for j in b:
      for k in c:
        n=i+j+k
        if n<thr+1:
          break
        m+=1
        l+=[n]
  l.sort(reverse=True)
  return l+[thr]*(q-len(l))
thr=bisect(0,a[0]+b[0]+c[0]+1)
ans=make(thr)
for w in ans:
  print(w)
### BUGGY CODE ###

N = int(input())
L = list(map(int,input().split()))
L.sort()

def b_search(L,key,left,right):
    #L[i] < keyを満たす最大のi
    #L[i] < key <= L[i+1]
    if key <= L[left]:
        return 0
    elif key > L[len(L)-1]:
        return len(L)
    while left < right:
        mid = (left + right) // 2
        if L[mid] < key and key <= L[mid+1]:
            return mid + 1
        elif L[mid] >= key:
            right = mid
        else:
            left = mid

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        ans += b_search(L,L[i]+L[j],0,len(L))-(j+1)
print(ans)


### FIXED CODE ###

from bisect import bisect_left

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        ans += bisect_left(L,L[i]+L[j])-(j+1)
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
n, q = map(int, input().split(' '))
     
inf = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split(' '))
    inf[a-1].append(b-1)
    inf[b-1].append(a-1)
point = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, input().split(' '))
    point[p-1] += x
def add_p(num, oya):
    for k in inf[num]:
        if k != oya:
            point[k] += point[num]
            add_p(k, num)  
for i in inf[0]:
    point[i] += point[0]
    add_p(i,0)
print(*point)

### FIXED CODE ###

def main():
    n, q = map(int, input().split(' '))
    import sys
    from collections import deque
    sys.setrecursionlimit(10**7)

    visit = [True for _ in range(n)]
    point = [0 for _ in range(n)]
    dic = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(int, input().split(' '))
        dic[a-1].append(b-1)
        dic[b-1].append(a-1)
    for _ in range(q):
        p, x = map(int, input().split(' '))
        point[p-1] += x
    next_visit = deque()
    next_visit.append(0)
    visit[0] = False
    counter = 1
    while counter < n:
        t = next_visit.pop()
        for s in dic[t]:
            if visit[s]:
                point[s] += point[t]
                visit[s] = False
                counter += 1
                next_visit.append(s)
    print(*point)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,*a = map(int,open(0).read().split())
mod = 10**9+7
print(sum([sum([a[i]^j for j in a[i+1:]]) for i in range(n-1)])%mod)

### FIXED CODE ###

import numpy as np
n,*a = map(int,open(0).read().split())
a = np.array(a)
mod = 10**9+7
ans = 0
for i in range(61):
  b = np.count_nonzero(a>>i&1)
  ans += b*(n-b)*1<<i
print(ans%mod)
### BUGGY CODE ###

n=int(input())
s=[]
for i in range(n):
    s.append(input())

s=sorted(s)
t=0
c=0
ct=[]
for i in range(1,n):
    c+=1
    if s[t]!=s[i]:
        ct.append(c)
        c=0
        t=i
ct.append(c+1)
u=0
for i in ct:
    if i==max(ct):
        print(s[u])
    u+=i


### FIXED CODE ###

n=int(input())
s=[]
for i in range(n):
    s.append(input())
s=sorted(s)
t=0
c=0
ct=[]
for i in range(1,n):
    c+=1
    if s[t]!=s[i]:
        ct.append(c)
        c=0
        t=i
ct.append(c+1)
u=0
cm=max(ct)
for i in ct:
    if i==cm:
        print(s[u])
    u+=i
### BUGGY CODE ###

n = int(input())

s_dic = {}

for i in range(n):
    tmp = str(input())
    if tmp not in s_dic:
        s_dic[tmp] = 1
    else:
        s_dic[tmp] += 1


max_s_key = [s_value[0] for s_value in s_dic.items() if s_value[1] == max(s_dic.values())]

max_s_key = sorted(max_s_key)

for i in max_s_key:
    print(i)

### FIXED CODE ###

n = int(input())

s_dic = {}

for i in range(n):
    tmp = str(input())
    if tmp not in s_dic:
        s_dic[tmp] = 1
    else:
        s_dic[tmp] += 1

max_value = max(s_dic.values())
s_dic = sorted(s_dic.items(), key=lambda x:x[0])

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

import sys
import numpy as np
from numba import njit

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


@njit('i8[:](i8,i8,i8[:])', cache=True)
def func(n, k, A):
    for _ in range(k):
        B = np.zeros(n + 1, np.int64)
        for i, a in enumerate(A):
            B[max(0, i - a)] += 1
            B[min(i + a + 1, n)] -= 1
        A = B.cumsum()[:-1]
    return A


def main():
    N, K = map(int, readline().split())
    A = np.array(readline().split(), np.int64)
    ans = func(N, K, A)
    print(*ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import numpy as np
from numba import njit

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


@njit('i8[:](i8,i8,i8[:])', cache=True)
def func(n, k, A):
    for _ in range(k):
        B = np.zeros(n + 1, np.int64)
        for i, a in enumerate(A):
            B[max(0, i - a)] += 1
            B[min(i + a + 1, n)] -= 1
        A = B.cumsum()[:-1]
        if np.all(A == n):
            break
    return A


def main():
    N, K = map(int, readline().split())
    A = np.array(readline().split(), np.int64)
    ans = func(N, K, A)
    print(*ans)


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

n = int(input())
ans = float('inf')
temp = 0
for i in range(1,(n//2)+2):
    if n%i == 0:
        temp = max(i, n//i)
        ans = min(temp, ans)
print(len(str(ans)))

### FIXED CODE ###

n = int(input())
ans = float('inf')
temp = 0
for i in range(int(n**(1/2)), 0, -1):
    if n%i == 0:
        temp = max(i, n//i)
        ans = min(temp, ans)
print(len(str(ans)))
### BUGGY CODE ###

class BIT:

    def __init__(self, N):
        # NOTE: 1-indexed
        self.N = N
        self.data = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & (- i)
        return s

    def update(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & (- i)


def c2n(c):
    return ord(c) - ord('a')


def main():
    N = int(input())
    S = input()
    char_list = list(S)
    trees = [BIT(N) for _ in range(26)]
    for i, c in enumerate(S):
        trees[c2n(c)].update(i + 1, 1)
    Q = int(input())
    ans = list()
    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            _, i, c = query
            i = int(i) - 1
            before_c = char_list[i]
            char_list[i] = c
            trees[c2n(before_c)].update(i + 1, - 1)
            trees[c2n(c)].update(i + 1, 1)
        else:  # type '2'
            _, left, right = query
            left, right = int(left) - 1, int(right) - 1
            cnt = 0
            for i in range(26):
                n = trees[i].sum(right + 1) - trees[i].sum(left)
                if n > 0:
                    cnt += 1
            ans.append(cnt)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

### FIXED CODE ###

class BIT:

    def __init__(self, N):
        # NOTE: 1-indexed
        self.N = N
        self.data = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & (- i)
        return s

    def update(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & (- i)


def c2n(c):
    return ord(c) - ord('a')


def main():
    N = int(input())
    S = input()
    char_list = list(S)
    trees = [BIT(N) for _ in range(26)]
    for i, c in enumerate(S):
        trees[c2n(c)].update(i + 1, 1)
    Q = int(input())
    ans = list()
    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            _, i, c = query
            i = int(i) - 1
            before_c = char_list[i]
            char_list[i] = c
            trees[c2n(before_c)].update(i + 1, - 1)
            trees[c2n(c)].update(i + 1, 1)
        else:  # type '2'
            _, left, right = query
            left, right = int(left) - 1, int(right) - 1
            cnt = 0
            for i in range(26):
                n = trees[i].sum(right + 1) - trees[i].sum(left)
                if n > 0:
                    cnt += 1
            ans.append(cnt)
    for a in ans:
        print(a)


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

N=int(input())
sum=0
for j in range(1,N+1):
    sum+=int(((N//j)*(N//j+1)/2)*j)
print(sum)


### FIXED CODE ###

N=int(input())
sum=0
for j in range(1,N+1):
    sum+=((N//j)*(N//j+1)//2)*j
print(sum)
### BUGGY CODE ###

from math import floor
def main():
    a, b, n = map(int, input().split())

    r = 0
    for i in range(n+1):
        r = max(r, floor(a*i/b) - floor(i/b)*a)
    print(r)

if __name__ == '__main__':
    main()


### FIXED CODE ###

from math import floor
def main():
    a, b, n= map(int, input().split())
    x = min(n, b - 1)
    r = floor((a * x) / b) - a * floor(x / b)
    print(r)

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

# N

K, S = map(int, input().split())

K+=1

count=0
for i in range(K):
    for j in range(K):
        for k in range(K):
            if i + j + k == S:
                count+=1
#                 print(i,j,k)
print(count)

### FIXED CODE ###

# N^2
K, S = map(int, input().split())

K+=1

count=0
for i in range(K):
    for j in range(0, K):
        tmp = S - (i + j)
        if tmp>=0 and tmp<K:
            count+=1
#             print(i,j,tmp)

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

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

mod = 10**9+7
ans = 0

for k in range(60):
    x, y = 0, 0
    for a in A:
        x += 1 & a>>k
    ans += x*(n-x)*pow(2, k, mod)
    ans %= mod
print(ans)

### FIXED CODE ###

def main():
    n = int(input())
    A = list(map(int, input().split()))

    mod = 10**9+7
    ans = 0

    for k in range(60):
        x, y = 0, 0
        for a in A:
            x += 1 & a>>k
        tmp = x*(n-x)%mod
        tmp *= pow(2, k, mod)
        ans += tmp
        ans %= mod
    print(ans)


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

import math
from collections import defaultdict

N, K = map(int, input().split())
# N = int(input())
al = list(map(int, input().split()))


def left_right(x, d):
    left = x - d - 0.5
    right = x + d + 0.5
    return left, right

for _ in range(K):
    dic = defaultdict(int)
    for i in range(N):
        l, r = left_right(i + 1, al[i])
        left = math.ceil(l)
        if left == 0:
            left += 1
        right = math.floor(r)
        for n in range(left, right + 1):
            dic[n] += 1
    al = list(dic.values())[:N]
print(*al)


### FIXED CODE ###

import math
from itertools import accumulate

N, K = map(int, input().split())
al = list(map(int, input().split()))
syusoku = [N] * N

for _ in range(K):
    s = [0] * N
    for i in range(N):
        left = i - al[i]
        right = i + al[i]
        if left < 0:
            left = 0
        s[left] += 1
        if right + 1 <= N - 1:
            s[right + 1] -= 1
        # print(left,right)
    al = list(accumulate(s))
    # print(al)
    if al == syusoku:
        print(*al)
        #print('end')
        exit()

print(*al)
### BUGGY CODE ###

import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    N, X = read_values()
    A = read_list()

    dp = [[[0 for _ in range(N * X + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    

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

    for i, a in enumerate(A):
        for j in range(N + 1):
            for k in range(N * X):
                if k + a <= N * X and j < N:
                    dp[i + 1][j + 1][k + a] += dp[i][j][k]
                dp[i + 1][j][k] += dp[i][j][k]
    
    res = 0
    for i in range(1, N + 1):
        res += dp[N][i][i * X]

    print(res)


if __name__ == "__main__":
    main()



### FIXED CODE ###

import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    N, X = read_values()
    A = read_list()

    dp = [[[0 for _ in range(N * X + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    

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

    for i, a in enumerate(A):
        for j in range(N + 1):
            for k in range(N * X):
                if k + a <= N * X and j < N:
                    dp[i + 1][j + 1][k + a] += dp[i][j][k]
                dp[i + 1][j][k] += dp[i][j][k]
    
    res = 0
    for i in range(1, N + 1):
        res += dp[N][i][i * X]

    print(res)


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

K = int(input())

if K % 2 == 0:
  print(-1)
  exit()

if K % 7 == 0:
  K //= 7
k = 1
cnt = 1
while True:
  if k % K == 0:
    break
  k = (k * 10 + 1) % K
  cnt += 1

print(cnt)

### FIXED CODE ###

K = int(input())

if K % 2 == 0:
  print(-1)
  exit()

if K % 7 == 0:
  K //= 7
k = 1
cnt = 1
for i in range(10 ** 8):
  if k % K == 0:
    break
  k = (k * 10 + 1) % K
  cnt += 1
else:
  print(-1)
  exit()

print(cnt)
### BUGGY CODE ###

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

a_types = set(A)

count_dict = {}
for each in a_types:
    count_dict[each] = A.count(each)

result_dict = {}
for each in a_types:
    tmp_dict = copy.deepcopy(count_dict)
    tmp_dict[each] = count_dict[each] - 1
    combinations = 0
    for value in tmp_dict.values():
        combinations += int(value * (value - 1) / 2)
    result_dict[each] = combinations

for a in A:
    print(result_dict[a])

### FIXED CODE ###

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

c = [0]*n

for i in range(n):
    c[a[i]-1] = c[a[i]-1] + 1
    
total = 0
for x in c:
    total = total + x*(x-1)//2

for i in range(n):
    print(total - c[a[i]-1] + 1)
### BUGGY CODE ###

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


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

a.sort()
#print(a)
if k > 1:
    ans = 0
    for i in range(k-1, n):
        for j in range(0, i - k + 2):
            ans += (a[i] - a[j]) * cmb(i - j - 1, k - 2)
            #print(j, i, ' ', a[j],a[i], ' ', a[i] - a[j])
    ans %= pow(10, 9) + 7
    print(ans)
else:
    print(0)

### FIXED CODE ###

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = pow(10, 5)  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
mod = pow(10, 9) + 7

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

n,k = map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
if k > 1:
    ans = 0
    for i in range(k-1, n):
        maxs = a[i]
        ncr = cmb(i, k-1)
        #print(maxs, ncr, maxs * ncr)
        ans += maxs * ncr
        ans %= mod
    for i in range(n-k+1):
        mins = a[i]
        ncr = cmb(n-i-1, k-1)
        #print(mins, ncr, mins * ncr)
        ans -= mins * ncr
        ans %= mod
    print(ans)
else:
    print(0)
### BUGGY CODE ###

while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		ans = 0
		for sp in range(len(t)):
			for L in range(len(t)-sp):
				if t[sp:sp+L] in s:
					ans = max(ans,L)
		print ans
	except:
		break

### FIXED CODE ###

while 1:
	try:
		s,t = raw_input(),raw_input()
		if len(s) < len(t): s,t = t,s
		MAXL = sum(min(s.count(i),t.count(i)) for i in set(list(s))&set(list(t)))
		ans = 0
		for sp in range(len(t)):
			if len(t) - sp <= ans:
				break
			for L in range(ans+1,min(MAXL+1,len(t)-sp+1)):
				if t[sp:sp+L] in s:
					ans = L
				else:
					break
		print ans
	except:
		break
### BUGGY CODE ###

n, w = map(int, input().split())
dp = [0]*(w+1)

for i in range(n):
  weight, value = map(int, input().split())
  for j in range(w, -1, -1):
    if j == 0 or dp[j] != 0:
      if j+weight <= w:
        dp[j+weight] = max([dp[j+weight], dp[j]+value])

print(max(dp))

### FIXED CODE ###

n, w = map(int, input().split())
dp = [0]*(w+1)

for i in range(n):
  weight, value = map(int, input().split())
  for j in range(w, -1, -1):
    if j == 0 or dp[j] != 0:
      if j+weight <= w:
        dp[j+weight] = max([dp[j+weight], dp[j]+value])

print(max(dp))
### BUGGY CODE ###


def main():
    N, H = list(map(int, input().split()))
    a_max = 0
    b_list = []

    for _ in range(N):
        a,b = list(map(int, input().split()))
        a_max = max(a, a_max)
        b_list.append(b)

    b_list = sorted(b_list)[::-1]
    
    cnt = 0
    while H > 0:
        H -= b_list.pop(0) if len(b_list) > 0 and b_list[0] > a_max else a_max
        cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()


### FIXED CODE ###

# ABC85 D 
import math

def main():
    N, H = list(map(int, input().split()))
    a_max = 0
    b_list = []

    for _ in range(N):
        a,b = list(map(int, input().split()))
        a_max = max(a, a_max)
        b_list.append(b)

    b_list = sorted(b_list)[::-1]
    
    cnt = 0
    for b in b_list:
        if b < a_max:
            break
        if H <= 0:
            break
        H -= b
        cnt += 1
    
    if H > 0:
        print(cnt + math.ceil(H / a_max))
    else:
        print(cnt)

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

n = int(input())

A = [int(input()) for i in range(n)]

m = max(A)

print(max(A[1:]))

for i in range(1, n-1):
    if A[i] < m:
        print(m)
    else:
        print(max(max(A[:i]), max(A[i+1:])))

print(max(A[:n-1]))

### FIXED CODE ###

n = int(input())

A = [int(input()) for i in range(n)]

S = sorted(A)

m1 = max(A)
m2 = S[-2]

for a in A:
    if a != m1:
        print(m1)
    else:
        print(m2)