import bisect

n=int(eval(input()))

x=[int(eval(input()))for _ in range(n)]

a=[-x[0]]

l=1

for i in range(1,n):

  b=-x[i]

  if a[-1]>b:

    if a[0]>b:a[0]=b;continue

    a[bisect.bisect_right(a,b)]=b

  else:a.append(b);l+=1

print(l)
import bisect;n,a,l=int(eval(input())),[-int(eval(input()))],1

for i in range(n-1):

  b=-int(eval(input()))

  if a[-1]>b:a[bisect.bisect_right(a,b)]=b

  else:a.append(b);l+=1

print(l)
import bisect

n = int(eval(input()))
x = [int(eval(input())) for _ in range(n)]
a = [-x[0]]
l = 1
for i in range(1, n):
    b = -x[i]
    if a[-1] > b:
        if a[0] > b:
            a[0] = b
            continue
        a[bisect.bisect_right(a, b)] = b
    else:
        a.append(b)
        l += 1
print(l)

import bisect

n, a, l = int(eval(input())), [-int(eval(input()))], 1
for i in range(n - 1):
    b = -int(eval(input()))
    if a[-1] > b:
        a[bisect.bisect_right(a, b)] = b
    else:
        a.append(b)
        l += 1
print(l)

-n = int(eval(input())) -x = [int(eval(input())) for _ in range(n)] -a = [-x[0]] -l = 1 -for i in range(1, n): -    b = -x[i] +n, a, l = int(eval(input())), [-int(eval(input()))], 1 +for i in range(n - 1): +    b = -int(eval(input())) -        if a[0] > b: -            a[0] = b -            continue