N = int(eval(input()))

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

from bisect import bisect_right

from collections import deque



def LIS(L):

    dp = deque([L[0]])

    length = len(L)

    for i in range(1, length):

        a = L[i]

        if a >= dp[-1]:

            dp.append(a)

        else:

            dp[bisect_right(dp, a)] = a

    return dp



print((len(LIS(As[::-1]))))
import sys

def input(): return sys.stdin.readline().strip()

def mapint(): return list(map(int, input().split()))

sys.setrecursionlimit(10**9)



N = int(eval(input()))

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



from bisect import bisect_right

lis = [1]

for a in As:

    if a>=lis[-1]:

        lis.append(a)

    else:

        lis[bisect_right(lis, a)] = a



print((len(lis)))
N = int(eval(input()))
As = [int(eval(input())) for _ in range(N)]
from bisect import bisect_right
from collections import deque


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


print((len(LIS(As[::-1]))))

import sys


def input():
    return sys.stdin.readline().strip()


def mapint():
    return list(map(int, input().split()))


sys.setrecursionlimit(10**9)
N = int(eval(input()))
As = [-int(eval(input())) for _ in range(N)]
from bisect import bisect_right

lis = [1]
for a in As:
    if a >= lis[-1]:
        lis.append(a)
    else:
        lis[bisect_right(lis, a)] = a
print((len(lis)))

-N = int(eval(input())) -As = [int(eval(input())) for _ in range(N)] -from bisect import bisect_right -from collections import deque +import sys -def LIS(L): -    dp = deque([L[0]]) -    length = len(L) -    for i in range(1, length): -        a = L[i] -        if a >= dp[-1]: -            dp.append(a) -        else: -            dp[bisect_right(dp, a)] = a -    return dp +def input(): +    return sys.stdin.readline().strip() -print((len(LIS(As[::-1])))) +def mapint(): +    return list(map(int, input().split())) + + +sys.setrecursionlimit(10**9) +N = int(eval(input())) +As = [-int(eval(input())) for _ in range(N)] +from bisect import bisect_right + +lis = [1] +for a in As: +    if a >= lis[-1]: +        lis.append(a) +    else: +        lis[bisect_right(lis, a)] = a +print((len(lis)))