num = []
for _ in range(int(input())):
    num.append(int(input()))

for i in range(len(num)):
    a = max(num[:i]) if i > 0 else -1e9
    b = max(num[i+1:]) if i < len(num)-1 else -1e9
    print(max(a, b))