import sys
sys.setrecursionlimit(10**6)
from collections import deque
n = int(input())
l = deque([int(input()) for _ in range(n)][::-1])

for i in range(n):
    num = l.pop()
    print(max(l))
    l.appendleft(num)
        
        