n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    if i == n - 1:
        ans = max(a[:i])
    elif i == 0:
        ans = max(a[1:])
    else:
        ans = max(max(a[:i]), max(a[i+1:]))
    print(ans)