import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def main():
    n = int(input())
    As = [int(input()) for i in range(n)]
    mn = max(As)
    for i in range(n):
        if As[i] == mn:
            print(max(As[:i] + As[i+1:]))
        else:
            print(mn)
    return 

if __name__ == '__main__':
    main()