from bisect import bisect

N = int(eval(input()))

A = [-int(eval(input())) for _ in range(N)]

L = [A[0]]

for a in A[1:]:

    if a >= L[-1]:

        L.append(a)

    else:

        L[bisect(L, a)] = a

print((len(L)))
from bisect import bisect_right



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



A.reverse()



dp = [A[0]]

for a in A[1:]:

    if dp[-1] <= a:

        dp.append(a)

    else:

        dp[bisect_right(dp, a)] = a



print((len(dp)))

from bisect import bisect

N = int(eval(input()))
A = [-int(eval(input())) for _ in range(N)]
L = [A[0]]
for a in A[1:]:
    if a >= L[-1]:
        L.append(a)
    else:
        L[bisect(L, a)] = a
print((len(L)))

from bisect import bisect_right

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

-from bisect import bisect +from bisect import bisect_right -N = int(eval(input())) -A = [-int(eval(input())) for _ in range(N)] -L = [A[0]] +N, *A = list(map(int, open(0).read().split())) +A.reverse() +dp = [A[0]] -    if a >= L[-1]: -        L.append(a) +    if dp[-1] <= a: +        dp.append(a) -        L[bisect(L, a)] = a -print((len(L))) +        dp[bisect_right(dp, a)] = a +print((len(dp)))