import copy

def main():

    N = int(input())
    A = [int(input()) for _ in range(N)]

    srtdA = copy.copy(list(set(A)))
    srtdA.sort(reverse=True)

    for  i in range(N):
        if len(srtdA)==1:
            print(srtdA[0])
        elif A[i] == srtdA[0]:
            print(srtdA[1])
        else:
            print(srtdA[0])

if __name__== "__main__":
    main() 
