N = int(input())

l = []
for _ in range(N):
    l.append(input())

max_n = max(l)

for i in range(len(l)):
    tmp  = []
    if l[i] != max_n:
        print(max_n)
    else:
        for j in range(len(l)):
            if i == j:
                continue
            else:
                tmp.append(l[j])
        print(max(tmp))