def main():
    N = int(input())
    A = [int(input()) for i in range(N)]

    temp = 0
    minimum = -1
    for i in range(N):
        temp = A[i]
        A[i] = minimum
        print(max(A))
        A[i] = temp


if __name__ == '__main__':
    main()
