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

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