length = int(input())
suretsu=[int(input()) for i in range(length)]
result = []
for i in range(length):
    pop_suretsu = suretsu[0:i] + suretsu[i+1:]
    result.append(str(max(pop_suretsu)))
print('\n'.join(result))