from collections import deque
import sys
input = sys.stdin.readline
N = int(input())
A = deque([int(input()) for _ in range(N)])

for i in range(N):
    tmp = A.popleft()
    print(max(A))
    A.append(tmp)