N = int( input() )
c_list = []
for i in range(N):
    c_list.append( int( input() ) )
    
a = c_list[:]
a.sort()

for i in range(N):
    t = c_list[i]
    a_copy = a[:]
    a_copy.remove(t)
    print( a_copy[N - 2] )