CodeEff/ECCO huggingface dataset:
# Original solution
from collections import defaultdict
counts=defaultdict(int)
for c in input():counts[c]+=1
print("Yes"if all(counts[k]%2<1 for k in counts)else"No")

# Optimized solution
c={}
for k in input():c[k]=(c[k]if k in c else 0)+1
print("Yes"if all(c[k]%2<1 for k in c)else"No")
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

for check in list(Counter(read().rstrip().decode()).values()):
    if check % 2 == 1:
        print('No')
        exit()
print('Yes')


# Optimized solution
import sys
read = sys.stdin.buffer.read

from collections import Counter

print(('Yes' if all(v % 2 == 0 for v in list(Counter(read().rstrip().decode()).values())) else 'No'))
# Original solution
from collections import Counter


print('No') if any(v % 2 for v in Counter(input()).values()) else print('Yes')


# Optimized solution
cntr = [0] * 26
for c in input():
    cntr[ord(c) - 97] += 1
print('No') if any(v % 2 for v in cntr) else print('Yes')
# Original solution
import string
import sys

input = sys.stdin.readline
AL = string.ascii_lowercase


def main():
    w = input().rstrip()
    ans = "Yes"
    for s in AL:
        cnt = w.count(s)
        if cnt % 2 == 1:
            ans = "No"
    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    w = input().rstrip()

    c = Counter(w)
    ans = "Yes"
    for v in list(c.values()):
        if v % 2 != 0:
            ans = "No"

    print(ans)


if __name__ == "__main__":
    main()
# Original solution
from collections import deque
n=deque(int(eval(input())) for _ in range(int(eval(input()))))
for _ in range(len(n)): m=n.popleft();print((max(n)));n.append(m)

# Optimized solution
n=[int(eval(input())) for _ in range(int(eval(input())))]
N1,N2=max(n),sorted(n)[-2]
for i in n:
  if i<N1: print(N1)
  elif i==N1: print(N2)
# Original solution
import copy
n=int(eval(input()))
a=[int(eval(input())) for i in range(n)]
t=copy.deepcopy(a)
t.sort()
for i in a:
  if i==t[-1]:
    print((t[-2]))
    
  else:
    print((t[-1]))

# Optimized solution
n=int(eval(input()))
a=[int(eval(input())) for i in range(n)]
sa=sorted(a)

for i in a:
  if sa[-1]==i:
    print((sa[-2]))
  else:
    print((sa[-1]))
# Original solution
import copy
N = int(eval(input()))
A = []
for i in range(N):
    A.append(int(eval(input())))
c = []
mL = 0
mR = 0
# m = 0
m = max(A)
S = copy.copy(A)
for s in S:
    if s == m:
        S.remove(s)
    # print(S[i])
s = max(S)    
# print(s)
for i, a in enumerate(A):
    # print(a)
    if a == m:
        print(s)
    else:
        print(m)
    # if i == 0:
    #     mR = max(A[i + 1 :])
    #     print(mR)
    # elif i == len(A) - 1:
    #     mL = max(A[0: i])
    #     print(mL)
    # else:
    #     mL = max(A[0: i])
    #     mR = max(A[i + 1 :])
    #     m = max(mL, mR)
    #     print(m)
    

# Optimized solution
import copy
N = int(eval(input()))
A = []
m = 0
S = 0
for i in range(N):
    a = int(eval(input()))
    A.append(a)
    if m < a:
        s = m
        m = a
    elif s < a:
        s = a

c = []
mL = 0
mR = 0
# m = 0


for i, a in enumerate(A):
    # print(a)
    if a == m:
        print(s)
    else:
        print(m)
    # if i == 0:
    #     mR = max(A[i + 1 :])
    #     print(mR)
    # elif i == len(A) - 1:
    #     mL = max(A[0: i])
    #     print(mL)
    # else:
    #     mL = max(A[0: i])
    #     mR = max(A[i + 1 :])
    #     m = max(mL, mR)
    #     print(m)
# Original solution
import sys
# import numpy as np
from copy import deepcopy
input = sys.stdin.readline


def main():
    N = int(eval(input()))
    # A = np.array([int(input()) for _ in range(N)])
    A = [int(eval(input())) for _ in range(N)]
    # print(A)

    for j in range(N):
        B = deepcopy(A)
        del B[j]
        print((max(B)))
        # if j != A.index(max(A)):
        #     print(max(A))
        # else:
        #     ans = [x for i, x in enumerate(A) if i != j]
        #     print(max(ans))


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    As = [int(eval(input())) for _ in range(n)]

    As_sort = sorted(As)
    second, first = As_sort[-2:]
    for i in range(n):
        if As[i] == first:
            print(second)
        else:
            print(first)


if __name__ == "__main__":
    main()
# Original solution
import copy

n = int(eval(input()))
a_lst = []
for i in range(n):
    a = int(eval(input()))
    a_lst.append(a)

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        tmp = copy.copy(a_lst)
        tmp.remove(a)
        tmp = sorted(tmp)
        print((tmp[-1]))
    else:
        print(max_a)

# Optimized solution
n = int(eval(input()))
a_lst = []
for i in range(n):
    a = int(eval(input()))
    a_lst.append(a)

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        print((sorted_a_lst[-2]))
    else:
        print(max_a)
# Original solution
N = int(eval(input()))

Alist = [int(eval(input())) for i in range(N)]

for i in range(N):
    print((max(Alist[:i]+Alist[i+1:])))


# Optimized solution
N = int(eval(input()))

Alist = [int(eval(input())) for i in range(N)]

Blist = sorted(Alist, reverse=True)

for i in range(N):
    if Alist[i] == Blist[0]:
        print((Blist[1]))
    else:
        print((Blist[0]))
# Original solution
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]

ANS = []
for i in range(N):
  Alist = A[:i]+A[i+1:]
  ANS.append(max(Alist))

for i in ANS:
    print(i)


# Optimized solution
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]

maxA = max(A)
max_in = A.index(max(A))
ANS = [maxA]*N
ANS[max_in] = max(A[:max_in]+A[max_in+1:])

for i in ANS:
    print(i)
# Original solution
import copy

n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
for i in range(n):
    a_copy = copy.deepcopy(a)
    a_copy.pop(i)
    print((max(a_copy)))

# Optimized solution
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
a_sort = sorted(a, reverse=True)
for i in range(n):
    if a[i] == a_sort[0]:
        print((a_sort[1]))
    else:
        print((a_sort[0]))
# Original solution
n = int(eval(input()))
A = [int(eval(input())) for _ in range(n)]
for i in range(n):
  print((max(A[:i] + A[i+1:])))

# Optimized solution
n = int(eval(input()))
A = [int(eval(input())) for _ in range(n)]
max_num, second_num = sorted(A, reverse=True)[:2]

for a in A:
  if a==max_num: print(second_num)
  else: print(max_num)
# Original solution
from collections import Counter

n = int(eval(input()))
al = [int(eval(input())) for _ in range(n)]
al_s = sorted(al, reverse=True)
c = Counter(al_s)
ck = list(c.keys())
cv = list(c.values())


for a in al:
    if a == ck[0]:
        if cv[0] == 1:
            print((ck[1]))
        else:
            print((ck[0]))
    else:
        print((ck[0]))



# Optimized solution
n = int(eval(input()))
al = list(int(eval(input())) for _ in range(n))

al_s = sorted(al)
fir = al_s[-1]
sec = al_s[-2]

for a in al:
    if a == fir:
        print(sec)
    else:
        print(fir)
# Original solution
import copy
n = int(eval(input()))
s = []
for _ in range(n):
    s.append(int(eval(input())))
max_s = max(s)
d = copy.copy(s)
for i in range(n):
    if max_s != s[i]:
        print(max_s)
    else:
        d = copy.copy(s)
        del d[i]
        print((max(d)))

# Optimized solution
n = int(eval(input()))
s = []
second = 0
max_k = 0
for _ in range(n):
    k = int(eval(input()))
    max_k, min_k = max(k, max_k), min(k, max_k)
    second = max(min_k, second)
    s.append(k)
kk = s.index(max_k)
for i in range(n):
    if i != kk:
        print(max_k)
    else:
        print(second)
# Original solution
N = int(eval(input()))
s = [int(eval(input())) for i in range(N)]

for i in range(N):
  temp=[s[x] for x in range(i)]+[s[x] for x in range(i+1, N)]
  print((max(temp)))

# Optimized solution
N=int(eval(input()))
s=[int(eval(input())) for i in range(N)]

temp=s.copy()
s_max=max(temp)
temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
    print(s_max2)
# Original solution
import copy
N = int(eval(input()))

A = [0]*N

for r in range(N):
  A[r] = int(eval(input()))
Elias_A = copy.copy(A)
A.sort()
Sorted_A = copy.copy(A)
  
for r in range(N):
  A.remove(Elias_A[r])
  print((A[N-2]))
  A = copy.copy(Sorted_A)

# Optimized solution
N = int(eval(input()))
A = [0]*N

for r in range(N): A[r] = int(eval(input()))
A_max = max(A)
A_sec = sorted(A)[-2]

for r in range(N):
  if A[r] == A_max: print(A_sec)
  elif A[r] == A_sec: print(A_max)
  else: print(A_max)
# Original solution
n=int(eval(input()))
a=[int(eval(input()))for _ in range(n)]
maxmax=max(a)
for i in range(n):
  if a[i]==maxmax:
    print((sorted(a)[-2]))
  else:
    print(maxmax)


# Optimized solution
n=int(eval(input()))
a=[int(eval(input()))for _ in range(n)]
b=sorted(a)

for i in a:
  if i==b[-1]:
    print((b[-2]))
  else:
    print((b[-1]))
# Original solution
n = int(eval(input()))
a = list(int(eval(input())) for i in range(n))
ans = 0
for i in range(n):
    l = a[:]
    l.pop(i)
    print((max(l)))

# Optimized solution
n = int(eval(input()))
a = list(int(eval(input())) for i in range(n))
l = a[:]
l.sort(reverse=True)
x = l[0]
y = l[1]
ans = 0
for i in range(n):
    if a[i] == x:
        ans = y
    else:
        ans = x
    print(ans)
# Original solution
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
n = A.index(max(A))

for i in range(n):    
    print((max(A))) 
print((sorted(A)[-2]))
for i in range(N-n-1):
    print((max(A)))   

# Optimized solution
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
n = A.index(max(A))
m = max(A)
A.remove(max(A))

for i in range(n):    
    print(m)
print((max(A)))
for i in range(N-n-1):
    print(m)
# Original solution
import copy

n = int(eval(input()))
a = []

for i in range(n):
    a.append(int(eval(input())))

for i in range(n):
    buf = copy.deepcopy(a)
    buf.pop(i)
    print(("{}".format(max(buf))))

# Optimized solution
n = int(eval(input()))
a = []

for i in range(n):
    a.append(int(eval(input())))

_max = max(a)
max_idx = a.index(_max)
a.remove(_max)
second = max(a)
for i in range(n):
    if i == max_idx:
        print(("{}".format(second)))
    else:
        print(("{}".format(_max)))
# Original solution
import copy
n=int(eval(input()))
l=[int(eval(input())) for _ in range(n)]


k=sorted(l)
dic_lst={}
for i in l:
  if i not in dic_lst:
    dic_lst[i]=1
  else:
    dic_lst[i]+=1
for i in l:
  max_num=max(dic_lst.keys())
  if i<max_num:
    print(max_num)
  if i==max_num:
    if dic_lst[i]>1:
      print(max_num)
    elif dic_lst[i]==1:
      print((k[-2]))


# Optimized solution
n=int(eval(input()))
l=[int(eval(input())) for _ in range(n)]
k=sorted(l)

for i in l:
	if i<k[-1]:
		print((k[-1]))
	if i==k[-1]:
		print((k[-2]))
# Original solution
import copy
n=int(eval(input()))
l1=[int(eval(input())) for i in range(n)]

for i in range(n):
  l2 = copy.copy(l1)
  del l2[i]
  print((max(l2)))

# Optimized solution
n=int(eval(input()))
l1=[int(eval(input())) for i in range(n)]
l2=sorted(l1)
max1=l2[-1]
max2=l2[-2]
for i in l1:
  if i == max1:
    print(max2)
  else:
    print(max1)
# Original solution
import copy

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

jumpIndex = -1

for i in range(N):
    if i < jumpIndex:
        A.remove(A[i])
        print(tmpMax)
        continue
    tmp = copy.copy(A)
    tmp.remove(A[i])
    tmpMax = max(tmp)
    for j in range(i + 1, N):
        if A[i] == tmpMax:
            jumpIndex = i
    print(tmpMax)

# Optimized solution
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]

maxNum = max(A)
index = -1
for i in range(N):
    if A[i] == maxNum:
        index = i

for i in range(N):
    if i != index:
        print(maxNum)
        continue
    else:
        A.remove(maxNum)
        print((max(A)))
# Original solution
N = int(eval(input()))
from collections import Counter
A = []
for i in range(N):
  A.append(int(eval(input())))

sorted_A = sorted(A, reverse=True)  
for a in A:
  tmp_A = list(sorted_A)
  tmp_A.remove(a)
  print((tmp_A[0]))

# Optimized solution
N = int(eval(input()))
A = []
largest = -1
second_largest = -1
more_than_one_largetst = False

for i in range(N):
  a = int(eval(input()))
  A.append(a)
  if largest == a:
    more_than_one_largest = True
  else:
    if largest < a:
      second_largest = largest
      largest = a
      more_than_one_largest = False
    else:
      if second_largest < a:
        second_largest = a
      else:
        pass

for a in A:
  if a != largest:
    print(largest)
  else:
    if more_than_one_largest:
      print(largest)
    else:
      print(second_largest)
# Original solution
import copy
a = int(eval(input()))
a_list = []
for i in range(a):
    a_list.append(int(eval(input())))
b_list = copy.copy(a_list)
for i in range(len(a_list)):
    b_list.pop(i)
    print((max(b_list)))
    b_list = copy.copy(a_list)

# Optimized solution
import sys
a = int(eval(input()))
a_list = []
for i in range(a):
    a_list.append(int(eval(input())))
max_num = max(a_list)
if a_list.count(max_num) != 1:
    for i in range(a):
        print(max_num)
else:
    sec_num = sorted(a_list)[-2]
    for i in a_list:
        if i == max_num:
            print(sec_num)
        else:
            print(max_num)
# Original solution
import math
import copy
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(eval(input()))
    return x

neko = 0
nya = 0
nuko = 0

a = []
n = iin()
for i in range(n):
    a.append(iin())
    if neko < a[i]:
        neko = a[i]
b = copy.copy(a)
a.remove(neko)
nya = max(a)
for i in range(n):
    if b[i] == neko:
        print(nya)
    else:
        print(neko)

# Optimized solution
n = int(eval(input()))
a = []
for i in range(n):
    a.append(int(eval(input())))
b = sorted(a,reverse = True)
max1 = b[0]
max2 = b[1]
for i in a:
    print((max2 if i == max1 else max1))
# Original solution
n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
b = [num for num in a]
x = max(a)
for i in range(n) :
    if a[i] != x :
        print(x)
    else :
        b.remove(a[i])
        print((max(b)))
        b.append(a[i])

# Optimized solution
n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
x = max(a)
m = a.index(x)
a.remove(x)
y = max(a)
for i in range(n) :
    if i == m :
        print(y)
    else :
        print(x)
# Original solution
import heapq
n=int(eval(input()))
a=[-int(eval(input())) for i in range(n)]
for i in range(n):
  x=a[:i]+a[i+1:]
  heapq.heapify(x)
  print((-heapq.heappop(x)))

# Optimized solution
n=int(eval(input()))
a=[int(eval(input())) for i in range(n)]
b=[a[i] for i in range(n)]
b.sort()
m=b[n-1]
m2=b[n-2]
for i in range(n):
  if a[i]==m:
    print(m2)
  else:
    print(m)
# Original solution
N = int(eval(input()))

A = []
for i in range(N):
    A.append(int(eval(input())))
    
for i in range(N):
    tmp = A[i]
    A[i] = 0
    print((max(A)))
    A[i] = tmp

# Optimized solution
N = int(eval(input()))

A = []
for i in range(N):
    A.append(int(eval(input())))

M = sorted(A)

for i in range(N):
    if A[i] == M[-1]:
        print((M[-2]))
    else:
        print((M[-1]))
# Original solution
import sys
sys.setrecursionlimit(10**6)
from collections import deque
n = int(eval(input()))
l = deque([int(eval(input())) for _ in range(n)][::-1])

for i in range(n):
    num = l.pop()
    print((max(l)))
    l.appendleft(num)
        
        

# Optimized solution
n = int(eval(input()))
l = [int(eval(input())) for _ in range(n)]
max_num = max(l)
second_num = sorted(l)[-2]

for i in range(n):
   if l[i] == max_num:
       print(second_num)
   else:
       print(max_num)
# Original solution
import copy
n = int(eval(input()))
A = []
for i in range(n):
  a = int(eval(input()))
  A.append(a)
for i in range(n):
  A_ = copy.deepcopy(A)
  A_.pop(i)
  print((max(A_)))

# Optimized solution
n = int(eval(input()))
A = []
for i in range(n):
  a = int(eval(input()))
  A.append(a)
m = max(A)
c = A.count(m)

if len(set(A)) > 1:
	m2 = sorted(set(A))[-2]

bool = False
if c == 1:
  bool = True

for i in A:
  if bool and i==m:
    print(m2)
  else:
    print(m)
# Original solution
import math
import copy

def first(a):
 a=A

N=int(eval(input()))
A=list(map(int,[eval(input()) for i in range(N)]))


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

# Optimized solution
n = int(eval(input()))
list = [int(eval(input())) for i in range(n)]
list2 = sorted(list)
m1 = list2[-1]
m2 = list2[-2]
 
for i in list:
    if i == m1:
        print(m2)
    else:
        print(m1)
# Original solution
import copy

N = eval(input())
A = [0]*N
tmp = [0]*N

for i in range(0,N):
  tmp[i]=int(input())
for i in range(0,N):
  A[i] = copy.deepcopy(tmp)

for i in range(0,N):
  A[i].pop(i)
  print(max(A[i]))

# Optimized solution
N = int(input())
A = []
for i in range(0,N):
  A.append(int(input()))
A = list(enumerate(A))
A = sorted(A, key=lambda x: x[1])
max_A = A[N-1][1]
second_max_A = A[N-2][1]
A = sorted(A,key=lambda x: x[0])
for i in range(0,N):
  if A[i][1] == max_A:
    print(second_max_A)
  else:
    print(max_A)
# Original solution
n = int(eval(input()))
A = [int(eval(input())) for _ in range(n)]
max_id = A.index(max(A))
A = sorted(A, reverse=True)
for i in range(n):
    if i == max_id:
        # 最大値が取り除かれるので2番目に大きい数値を出力
        print((A[1]))
    else:
        # 最大値が残っているので，最大値を出力
        print((A[0]))

# Optimized solution
n = int(eval(input()))
A = [int(eval(input())) for _ in range(n)]
maxA = max(A)
maxIdx = A.index(maxA)
for i in range(n):
  if i != maxIdx:
    print(maxA)
  else:
    print((max(A[:i] + A[i + 1:])))
# Original solution
import copy
N=int(eval(input()))
A = [int(eval(input())) for i in range(N)]
big=max(A)
flag=0
for i in range(N):
    if A[i]==big:
        if flag==0:
            flag==1
            hoge=copy.copy(A)
            hoge.pop(i)
            bigger=max(hoge)
            if bigger==big:
                print(big)
            else:
                print(bigger)
        else:
            print(bigger)
    else:
        print(big)

# Optimized solution
N=int(eval(input()))
A = [int(eval(input())) for i in range(N)]
B=sorted(A)
big=max(A)
flag=0
big2=B[-2]
for i in A:
    if i==big:
        print(big2)
    else:
        print(big)
# Original solution
import copy
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]

for i in range(n):
  tmp = copy.deepcopy(a)
  tmp[i] = 0
  print((max(tmp)))
  tmp = a

# Optimized solution
n = int(eval(input()))
a  =[]
for i in range(n):
  x = int(eval(input()))
  a.append(x)
ma = max(a)
b = sorted(a)
for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print((b[-2]))
# Original solution
N = int(eval(input()))
A = list()
B = [0] * 200000

for i in range(N):
  i = int(eval(input()))
  A.append(i)

for k in range(N):
  if max(A) != A[k]:
    print((max(A)))
  else:
    B[k] = A[k]
    A[k] = 0
    print((max(A)))
    A[k] = B[k]

# Optimized solution
N = int(eval(input()))
A = list()

for i in range(N):
  i = int(eval(input()))
  A.append(i)
  
ma = max(A)
sa = sorted(A)

for k in range(N):
  if ma != A[k]:
    print(ma)
  else:
    print((sa[-2]))
# Original solution

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

a_max = max(a)
b = a.copy()
b.remove(a_max)
a_max_second = max(b)

for a_i in a:
    if a_i != a_max:
        print(a_max)
    else:
        print(a_max_second)

# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(eval(input())) for i in range(N)]
    L = [0]*(N+1)
    for i, a in enumerate(A, start=1):
        L[i] = max(L[i-1], a)

    R = [0]*(N+2)
    for i in range(N)[::-1]:
        R[i] = max(R[i+1], A[i])

    for i in range(N):
        print((max(L[i], R[i+1])))


if __name__ == '__main__':
    main()
# Original solution
from collections import deque
import sys
input = sys.stdin.readline
N = int(eval(input()))
A = deque([int(eval(input())) for _ in range(N)])

for i in range(N):
    tmp = A.popleft()
    print((max(A)))
    A.append(tmp)

# Optimized solution
import sys
input = sys.stdin.readline
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
B = sorted(A)
for x in A:
    if x == B[-1]:
        print((B[-2]))
    else:
        print((B[-1]))
# Original solution
import copy
N,*D=list(map(int,open(0).read().split()))
for i in range(N):
  A=copy.deepcopy(D)
  del A[i]
  print((max(A)))

# Optimized solution
N,*D=map(int,open(0).read().split())
S=sorted(D,reverse=True)
if S[1]==S[0]:
  [print(S[0]) for i in range(N)]
else:
  import numpy as np
  max_i=np.arange(N)[np.array(D)==S[0]]
  for i in range(N):
    if i==max_i:
      print(S[1])
    else:
      print(S[0])
# Original solution
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
for i in range(N):
    tmp = A.copy()
    tmp.pop(i)
    tmp.sort()
    print((tmp[-1]))


# Optimized solution
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
As = sorted(A)
for i in range(N):
    if A[i] == As[-1]:
        print((As[-2]))
    else:
        print((As[-1]))
# Original solution
N = int(eval(input()))
A = []
for i in range(N):
  a = int(eval(input()))
  A.append(a)
  
A2 = sorted(A)
mx1 = A2[-1]
mx2 = A2[-2]

for i in range(N):
  if i == A.index(mx1):
    print(mx2)
  else:
    print(mx1)


# Optimized solution
N = int(eval(input()))
A = []
for i in range(N):
  a = int(eval(input()))
  A.append(a)
  
A2 = sorted(A)
mx1 = A2[-1]
mx2 = A2[-2]
ind = A.index(mx1)

for i in range(N):
  if i != ind:
    print(mx1)
  else:
    print(mx2)
# Original solution
a=int(eval(input()))
b=[int(eval(input())) for i in range(a)]
m=max(b) 

if b.count(m)>=2:
    for i in range(a):
        print (m)
else:
    c=b.copy()
    c.sort(reverse=True)
    m2=c[1]
    for i in range(a):
        if b[i]==m:
            print(m2)
        else:
            print (m)
            



# Optimized solution
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
maxa = max(a)
# print(maxa)
if a.count(maxa) == 1:
    b = sorted(a, reverse=True)

    maxa2 = b[1]
    for i in range(n):
        if a[i] == maxa:
            print(maxa2)
        else:
            print(maxa)

else:
    for i in range(n):
        print(maxa)
# Original solution
n = int(eval(input()))
numList  = [int(eval(input())) for _ in range(n)]
maxVal = max(numList)
workList = numList[:]
workList.remove(maxVal)
secondVal = max(workList)
for num in numList:
  if num != maxVal:
    print(maxVal)
  else:
    print(secondVal)

# Optimized solution
import sys
input = sys.stdin.readline
 
def main():
    N = int(eval(input()))
    A = [int(eval(input())) for _ in range(N)]
    max_val = max(A)
    AA = A[:]
    AA.remove(max_val)
    second_max_val = max(AA)
    for a in A:
        if a != max_val:
            print(max_val)
        else:
            print(second_max_val)
 
if __name__ == '__main__':
    main()
# Original solution
import copy

N = int(eval(input()))
A_list= []

for _ in range(N):
    A_list.append(int(eval(input())))

for i, a in enumerate(A_list):
    temp_A_list = copy.copy(A_list)
    temp_A_list.pop(i)
    print((max(temp_A_list)))

# Optimized solution
N = int(eval(input()))
A_list= []
for _ in range(N):
    A_list.append(int(eval(input())))

sorted_A_list = sorted(A_list, reverse=True)

for a in A_list:
    if a == sorted_A_list[0]:
        ans = sorted_A_list[1]
    else:
        ans = sorted_A_list[0]
    print(ans)
# Original solution
import sys
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]
tmp = sorted(A)
for i in range(n):
    if A[i] == max(A):
        print((tmp[-2]))
    else:
        print((max(A)))

# Optimized solution
import sys
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(n)]
tmp = sorted(A)
maxa = max(A)
for i in range(n):
    if A[i] == maxa:
        print((tmp[-2]))
    else:
        print(maxa)