n = int(input())
_list = []

for _ in range(n):
    _list.append(int(input()))

maxi = 0
for i in range(n):
    if i==0:
        tmp_list = _list[1:]
    elif 0<i<n-1:
        tmp_list = _list[:i] + _list[i+1:]
    else:
        tmp_list = _list[:n-1]

    tmp_max = max(tmp_list)
    print(tmp_max)