n = int(input())
a = [int(input()) for i in range(n)]
dp = [0 for i in range(n)]
dp[0] = a[0]
length = 1
for i in range(1, n):
    if dp[length-1] < a[i]:
        dp[length] = a[i]
        length += 1        
    else:
        for j in range(length):
            if dp[j] >= a[i]:
                dp[j] = a[i]
                break
print(length)
