def resolve():
    a = [int(input()) for _ in range(int(input()))]
    st = sorted(a)
    count = len(st)
    for i in a:
        index = st.index(i)
        if index == (count - 1):
            print(st[-2])
        else:
            print(st[-1])


resolve()