from array import array
n = int(input())
a_list = [int(input()) for _ in range(n)]
max_num = max(array('L',a_list))
for i in range(len(a_list)):
    if a_list[i] != max_num:
        print(max_num)
    else:
        print(max(array('L',a_list[:i]+a_list[i+1:])))