num = int(input())

arr = []

for i in range(num):
    arr.append(int(input()))

for i in range(num):
    if i == 0:
        print(int(max(arr[1:])))
    elif i == num-1:
        print(int(max(arr[:-1])))
    else:  
        print(int(max(arr[:i]+arr[i+1:])))