N = int(input())

a = []
for i in range(N):
    a.append(int(input()))
  
for j in range(N):
    if j == 0:
        print(max(a[j+1:N]))
    elif j == N:
        print(max(a[0:j]))
    else:
        if max(a[0:j]) > max(a[j+1:N]):
            print(max(a[0:j]))
        else:
            print(max(a[j:N]))