import sys

input = sys.stdin.readline

n = int(eval(input()))

if n == 1:

  print((1))

  exit()

  

chk = []

for i in range(n):

  a = int(eval(input()))

  chk.append((i,a))

  

from bisect import bisect_left,insort_left

from collections import deque

ans = 1



c = deque([])

for j in chk:

  i,a = j

  if i == 0:

    c.append((a,n-i))

  else:

    ind = bisect_left(c,(a,n-i))

    if ind == 0:

      ans += 1

      c.appendleft((a,n-i))

    else:

      c[ind-1] = (a,n-i)

      

print(ans)
import sys

input = sys.stdin.readline

n = int(eval(input()))

if n == 1:

  print((1))

  exit()

  

chk = []

for i in range(n):

  a = int(eval(input()))

  chk.append(a)

  

from bisect import bisect_left,insort_left

from collections import deque

ans = 0



c = deque([])

for j in chk:

  if i == 0:

    c.append(j)

  else:

    ind = bisect_left(c,j)

    if ind == 0:

      ans += 1

      c.appendleft(j)

    else:

      c[ind-1] = (j)

      

print(ans)
import sys

input = sys.stdin.readline
n = int(eval(input()))
if n == 1:
    print((1))
    exit()
chk = []
for i in range(n):
    a = int(eval(input()))
    chk.append((i, a))
from bisect import bisect_left, insort_left
from collections import deque

ans = 1
c = deque([])
for j in chk:
    i, a = j
    if i == 0:
        c.append((a, n - i))
    else:
        ind = bisect_left(c, (a, n - i))
        if ind == 0:
            ans += 1
            c.appendleft((a, n - i))
        else:
            c[ind - 1] = (a, n - i)
print(ans)

import sys

input = sys.stdin.readline
n = int(eval(input()))
if n == 1:
    print((1))
    exit()
chk = []
for i in range(n):
    a = int(eval(input()))
    chk.append(a)
from bisect import bisect_left, insort_left
from collections import deque

ans = 0
c = deque([])
for j in chk:
    if i == 0:
        c.append(j)
    else:
        ind = bisect_left(c, j)
        if ind == 0:
            ans += 1
            c.appendleft(j)
        else:
            c[ind - 1] = j
print(ans)

-    chk.append((i, a)) +    chk.append(a) -ans = 1 +ans = 0 -    i, a = j -        c.append((a, n - i)) +        c.append(j) -        ind = bisect_left(c, (a, n - i)) +        ind = bisect_left(c, j) -            c.appendleft((a, n - i)) +            c.appendleft(j) -            c[ind - 1] = (a, n - i) +            c[ind - 1] = j