# -*- coding: utf-8 -*-

import math

if __name__ == '__main__':
    N = int(input())
    A = []
    current_max = -1
    for i in range(N):
        A.append(int(input()))

    for i in range(N):
        b = [current_max] + A[i+1:]
        maxb = max(b)
        print(maxb)
        if maxb > current_max:
            current_max = maxb

