# -*- coding: utf-8 -*-

n = int(input())

a = list()
for i in range(n):
    a.append(int(input()))

a_sorted = sorted(a, reverse=True)

for i in range(n):
    index = a_sorted.index(a[i])
    if index == 0:
        print(a_sorted[index + 1])
        continue

    print(a_sorted[0])
