import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    A = [int(sys.stdin.readline().rstrip()) for _ in range(N)]

    for n in range(N):
        l = len(A)
        a = A[0:n] if len(A[0:n]) > 0 else [0]
        b = A[n + 1:l] if len(A[n + 1: l]) else [0]
        print(max(max(a), max(b)))


if __name__ == '__main__':
    main()
