import copy

N = int(input())
sequences = [int(input()) for _ in range(N)]

for i in range(N):
        tmp = copy.copy(sequences)
        tmp.pop(i)
        tmp_set = set(tmp)
        print(max(tmp_set))