from sys import stdin

readline = stdin.readline


def nf():
    """
    入力全て(EOFまで)を`int iter`に変換
    """
    return map(int, open(0).read().split())


def main():
    n, *l = nf()
    al = list(l)
    for i in range(n):
        ma = 0
        if i > 0:
            ma = max(al[:i])
        if i < n-1:
            ma = max(max(al[i+1:]), ma)
        print(ma)


if __name__ == "__main__":
    main()
