def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [int(input().rstrip('\n')) for _ in range(n)]
    b = sorted(a.copy(), reverse=True)
    for i in a:
        if i == b[0]:
            print(b[1])
        else:
            print(b[0])


if __name__ == '__main__':
    main()
