import bisect

N = int(input())
numbers = []
for i in range(N):
    numbers.append(int(input()))

lis = [numbers[0]]
for last in numbers[1:]:
    pos = bisect.bisect_left(lis, last)
    if len(lis) < pos:
        lis.append(last)
    else:
        lis = lis[:pos] + [last] + lis[pos+1:]

print(len(lis))