n=int(eval(input()))

a=[-int(eval(input())) for i in range(n)]

from bisect import bisect_right

l=[]

for aa in a:

  idx=bisect_right(l,aa)

  if idx==len(l):

    l.append(aa)

  else:

    l[idx]=aa

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

def LIS(l):

    length = [l[0]]

    for i in range(1, len(l)):

        if l[i] >= length[-1]:

            length.append(l[i])

        else:

            pos = bisect_right(length, l[i])

            length[pos] = l[i]

    return len(length)



n = int(eval(input()))

a = [int(eval(input())) for i in range(n)]

a = a[::-1]

print((LIS(a)))

n = int(eval(input()))
a = [-int(eval(input())) for i in range(n)]
from bisect import bisect_right

l = []
for aa in a:
    idx = bisect_right(l, aa)
    if idx == len(l):
        l.append(aa)
    else:
        l[idx] = aa
print((len(l)))

from bisect import bisect_right


def LIS(l):
    length = [l[0]]
    for i in range(1, len(l)):
        if l[i] >= length[-1]:
            length.append(l[i])
        else:
            pos = bisect_right(length, l[i])
            length[pos] = l[i]
    return len(length)


n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
a = a[::-1]
print((LIS(a)))

-n = int(eval(input())) -a = [-int(eval(input())) for i in range(n)] -l = [] -for aa in a: -    idx = bisect_right(l, aa) -    if idx == len(l): -        l.append(aa) -    else: -        l[idx] = aa -print((len(l))) + +def LIS(l): +    length = [l[0]] +    for i in range(1, len(l)): +        if l[i] >= length[-1]: +            length.append(l[i]) +        else: +            pos = bisect_right(length, l[i]) +            length[pos] = l[i] +    return len(length) + + +n = int(eval(input())) +a = [int(eval(input())) for i in range(n)] +a = a[::-1] +print((LIS(a)))