def main():
    N = int(input())

    A = [int(input()) for _ in range(N)]

    for i in range(len(A)):
        ans = calcMax(A, i)
        print(ans)



def calcMax(A, i):
    ans = max(A)
    if not ans == A[i]:
        return ans

    else:
        tmp = A[i]
        A[i] = 0
        ans = calcMax(A, i)
        A[i] = tmp
        return ans

if __name__ == '__main__':
    main()
