N = int(input())
a = [int(input()) for _ in range(N)]
for i in range(N):
    front = a[:i]
    back = a[i + 1:]
    f_max = max(front) if front else 0
    b_max = max(back) if back else 0
    print(max(f_max, b_max))