from bisect import bisect_left

n = int(input())
a = []
for _ in range(n):
    a += [int(input())]

def lis(A):
    L = [A[0]]
    for a in A[1:]:
        if a > L[-1]:
            L.append(a)
        else:
            L[bisect_left(L,a)] = a
    return len(L)
print(lis(a))
