import sys
import math
import copy
a = int(input());
b = [int(input()) for i in range(a)];
c = 0;
f = max(b);
for i in range(a):
    if max(b) > b[i]:
        print(f);
    elif max(b) == b[i]:
        d = copy.copy(b);
        del d[i]
        e = max(d);
        print(e);
