#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    n = int(input())
    [numbers.append(int(input().rstrip())) for _ in range(n)]
    s_numbers=sorted(numbers)

    for i in numbers:
        if i == max(numbers):
            print(s_numbers[-2])
        else:
            print(s_numbers[-1])
    

if __name__=="__main__":
    main()