def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    for i in range(n):
        d = sorted(a, reverse=True)
        if d[0] == a[i]:
            print(d[1])
        else:
            print(d[0])
            
if __name__ == '__main__':
    main()