from collections import deque

from bisect import bisect_left

N=int(eval(input()))

li=[]

ans=0

for i in range(N):

    a=-int(eval(input()))

    b=bisect_left(li,a+1)

    if b==len(li):

        li.append(a)

        ans+=1

    else:

        li[b]=a

print(ans)
from collections import deque

from bisect import bisect_left

N=int(eval(input()))

d=deque()

for i in range(N):

    A=int(eval(input()))

    b=bisect_left(d,A)-1

    if b==-1:

        d.appendleft(A)

    else:

        d[b]=A

print((len(d)))
from collections import deque
from bisect import bisect_left

N = int(eval(input()))
li = []
ans = 0
for i in range(N):
    a = -int(eval(input()))
    b = bisect_left(li, a + 1)
    if b == len(li):
        li.append(a)
        ans += 1
    else:
        li[b] = a
print(ans)

from collections import deque
from bisect import bisect_left

N = int(eval(input()))
d = deque()
for i in range(N):
    A = int(eval(input()))
    b = bisect_left(d, A) - 1
    if b == -1:
        d.appendleft(A)
    else:
        d[b] = A
print((len(d)))

-li = [] -ans = 0 +d = deque() -    a = -int(eval(input())) -    b = bisect_left(li, a + 1) -    if b == len(li): -        li.append(a) -        ans += 1 +    A = int(eval(input())) +    b = bisect_left(d, A) - 1 +    if b == -1: +        d.appendleft(A) -        li[b] = a -print(ans) +        d[b] = A +print((len(d)))