import numpy as np
N = int(input())
a_list = []
for _ in range(N):
    a_list.append(int(input()))
inds = list(np.argsort(a_list))
for i in range(N):
    tmp = inds.copy()
    tmp[i] = -1
    print(a_list[np.argmax(tmp)])