def func():
    input_num = int(input(''))
    a_i = [int(input('')) for i in range(input_num) ]
    frag, count = True, [0]*input_num
    count = [1 for i in range(input_num) if a_i[0] == a_i[i]]
    if sum(count) >= 2:
         frag = False
    if frag == True:
        value = [[a_i[i] if a_i[i] != a_i[j] else 0 for i in range(input_num )] for j in range(input_num)]
    else:
        value = [[a_i[i]for i in range(input_num )] for j in range(input_num)]
    for i in range(input_num):
        print(max(value[i]))
if __name__ == '__main__':
    func()