import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

from collections import deque

n = int(input())
a = deque()
for _ in range(n):
    a.append(int(input()))

for _ in range(n):
    tmp = a.popleft()
    print(max(a))
    a.append(tmp)
