import math

def main(): 

    n = int(input())
    a = [int(input()) for _ in range(n)]

    max_value = max(a)

    for i in range(n):
        if a[i] != max_value:
            print(max_value)
        else:
            t = list(a)
            t.pop(i)

            print(max(t))




if __name__ == "__main__":
    main() 