# -*- coding: utf-8 -*-

n = int(input())

a = []

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

for i in range(0,n):
    a1 = a[:i]
    a2 = a[i+1:]
    
    if len(a1) == 0:
        print(max(a2))
    elif len(a2) == 0:
        print(max(a1))
    else:
        print(max(max(a1), max(a2)))
