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

for i in range(n):
    if i == 0:
        tmp = a_lst[i+1:]
    elif i == n-1:
        tmp = a_lst[:i]
    else:
        tmp = a_lst[:i] + a_lst[i+1:]
    print(max(tmp))