import copy

def main():
    n = int(input())
    num_list = [int(input()) for _ in range(n)]
    
    for i in range(n):
        tmp = copy.deepcopy(num_list)
        tmp.pop(i)
        print(max(set(tmp)))
        
if __name__ == '__main__':
    main()