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

lis = [-float("inf"),numbers[0]]
for last in numbers[1:]:
    for i, (left, right) in enumerate(zip(lis, lis[1:])):
        if left < last and last < right:
            lis = lis[:i+1] + [last] + lis[i+2:]
            break
    if lis[-1] < last:
        lis.append(last)

print(len(lis)-1)