from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
AA = [inp() for _ in range(N)]
x = sorted(AA)
M1 = x[-1]
M2 = x[-2]

print(M1,M2)

for a in AA:
    if a == M1:
        print(M2)
    else:
        print(M1)
