n = int(input())

arr = []
max_num = 0
label = 1
for i in range(n):
    inp = int(input())
    if inp >= max_num:
       max_num = inp
       label = i
    arr.append(inp)


arr_sub = arr[:]
arr_sub.pop(label)
#print(arr)
#print(max(arr))
#print(max(arr_sub))



for i in range(n):
    if i != label:
        print(max(arr))
    else:
        print(max(arr_sub))


