import copy
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
a_cp = copy.copy(a)
result = []
for i in range(n):
    a.pop(i)
    result.append(max(a))
    a = copy.copy(a_cp)
for j in result:
    print(j)