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

import math

if __name__ == '__main__':
    N = int(input())
    A = []
    current_max = -1
    for i in range(N):
        A.append(int(input()))

    index = sorted(range(len(A)), key=lambda k: A[k])
    value = sorted(A)

    # print(A)

    for i in range(N):
        if index[i] < N-1:
            print(value[N-1])
        else:
            print(value[N-2])