# -*- coding: utf-8 -*-
def ExceptionHandling(arr_len, origin_arr):
    for i in range(arr_len):
        arr = list(origin_arr);
        arr.pop(i);
        print(max(arr))
        arr = origin_arr;

if __name__ == "__main__":
    N = int(input());
    A = [];
    for i in range(N):
        A.append(int(input()));
    ExceptionHandling(N,A)
