n = int(input())
li_a = list()
d_a = dict()

for _ in range(n):
    wk = int(input())
    li_a.append(wk)

    get = d_a.get(wk, 0)
    d_a[wk] = get + 1

for i in range(n):
    d_a_copy = d_a.copy()
    if d_a_copy.get(li_a[i], 0) == 1:
        d_a_copy.pop(li_a[i])
    print(max(d_a_copy.keys()))


