N = int(input())
data = []
for i in range(N):
    data.append(int(input()))

for i in range(N):
    M = max(data)
    if data[i] == M:
        data[i] = 0
        m_d = max(data)
        print(m_d)
        data[i] = M
    else:
        print(M)
