import sys

def solve(n, d):
    d_sorted = sorted(d, reverse=True)
    for i in range(n):
        print d_sorted[0] if d[i] != d_sorted[0] else d_sorted[1]


if __name__ == '__main__':

    n = int(sys.stdin.readline().strip())
    d = []
    for i in range(n):
        d.append(int(sys.stdin.readline().strip()))
    solve(n, d)