N = int(input())
ary = []
for i in range(N):
    ary.append(int(input()))
tmp = []
for i in range(N):
    for j in range(0,i):
        tmp.append(ary[j])
    for k in range(i+1,N):
        tmp.append((ary[k]))
    print(max(tmp))
    tmp = []