N, *d = map(int, open(0).read().split())
allmax = 0
for i in range(N):
    if d[i] > allmax:
        allmax = d[i]
for i in range(N):
    max = 0
    for j in range(N):
        if(i == j):
            continue
        if d[j] > max:
            max = d[j]
            if max == allmax:
                break
    print(max)