from bisect import bisect
n = int(input())
A = []
for i in range(n):
 A.append(int(input()))
 
 L = [None for i in range(n)]
def LIS():
    L[0] = A[0]
    length = 0
    for i in range(n):
        if L[length] < A[i]:
            length += 1
            L[length] = A[i]
        else:
            j = bisect(L, A[i], 0, length)
            L[j] = A[i]
    return length + 1

print(LIS())