def binary_search(key):

    bad, good = -1, len(ans)

    while good - bad > 1:

        mid = (bad + good) // 2

        if ans[mid][-1] < key:

            good = mid

        else:

            bad = mid

    return good





N = int(eval(input()))

ans = []

for _ in range(N):

    A = int(eval(input()))

    idx = binary_search(A)

    if idx == len(ans):

        ans.append([A])

    else:

        ans[idx].append(A)

print((len(ans)))

from bisect import bisect_right





N, *A = list(map(int, open(0).read().split()))

A = [-a for a in A]

q = []

for a in A:

    idx = bisect_right(q, a)

    if idx == len(q):

        q.append(a)

    else:

        q[idx] = a

print((len(q)))

def binary_search(key):
    bad, good = -1, len(ans)
    while good - bad > 1:
        mid = (bad + good) // 2
        if ans[mid][-1] < key:
            good = mid
        else:
            bad = mid
    return good


N = int(eval(input()))
ans = []
for _ in range(N):
    A = int(eval(input()))
    idx = binary_search(A)
    if idx == len(ans):
        ans.append([A])
    else:
        ans[idx].append(A)
print((len(ans)))

from bisect import bisect_right

N, *A = list(map(int, open(0).read().split()))
A = [-a for a in A]
q = []
for a in A:
    idx = bisect_right(q, a)
    if idx == len(q):
        q.append(a)
    else:
        q[idx] = a
print((len(q)))

-def binary_search(key): -    bad, good = -1, len(ans) -    while good - bad > 1: -        mid = (bad + good) // 2 -        if ans[mid][-1] < key: -            good = mid -        else: -            bad = mid -    return good +from bisect import bisect_right - -N = int(eval(input())) -ans = [] -for _ in range(N): -    A = int(eval(input())) -    idx = binary_search(A) -    if idx == len(ans): -        ans.append([A]) +N, *A = list(map(int, open(0).read().split())) +A = [-a for a in A] +q = [] +for a in A: +    idx = bisect_right(q, a) +    if idx == len(q): +        q.append(a) -        ans[idx].append(A) -print((len(ans))) +        q[idx] = a +print((len(q)))