from bisect import bisect_left
n = int(input())
A = [int(input()) for i in range(n)]
L = [A[0]]
a = A[0]
for i in A[1:]:
    if L[-1] < i:
        L.append(i)
    else:
        L[bisect_left(L, i)] = i
    a = i
print(len(L))
