import copy
length = int(input())
suretsu=[int(input()) for i in range(length)]
result = []
zantei_max = max(suretsu)
for i in range(length):
    if (zantei_max == suretsu[i]):
        copy_suretsu = copy.deepcopy(suretsu)
        del copy_suretsu[i]
        new_max = max(copy_suretsu)
        result.append(str(new_max))
    else:
        result.append(str(zantei_max))
print('\n'.join(result))