# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    for _ in range(N):
        print(max(A[0:_]+A[_+1:N]))
                

    

if __name__ == '__main__':
    main()