import math

n = int(input())

arr = []
s_arr = []

for i in range(n):
    a = int(input())
    arr.append(a)
    s_arr.append(a)

s_arr.sort()

for a in arr:
    if a >= s_arr[0]:
        print(s_arr[1])
    else:
        print(s_arr[0])
