n = int(input())
alist = [int(input()) for _ in range(n)]

import copy

alist_copy = copy.copy(alist)
for i, v in enumerate(alist):
    alist_copy.pop(i)
    print(max(alist_copy))
    alist_copy = copy.copy(alist)