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

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