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

import copy

N = int(input())
A = [int(input()) for i in range(N)]

Amax = max(A)

for i in range(N):
        if A[i] == Amax:
                TMP = copy.deepcopy(A)
                TMP.pop(i)
                print(max(TMP))
        else:
                print(Amax)
                