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

    B = list(set(sorted(A)))
    for n in A:
        if B[-1] != n or len(B) == 1:
            ret.append(B[-1])
        else:
            ret.append(B[-2])

    for r in ret:
        print(r)