import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]
INF = 10**18
arr = deque([])
for a in A:
    l, r = -1, len(arr)
    while (r-l) > 1:
        mid = (r+l)//2
        if arr[mid] < a:
            l = mid
        else:
            r = mid
    if l == -1:
        arr.appendleft(a)
    else:
        arr[l] = a
print(len(arr))
6a9159912b29099c44ed1ece905eba177bc04e43
<mask token>

<mask token>
for a in A:
    l, r = -1, len(arr)
    while r - l > 1:
        mid = (r + l) // 2
        if arr[mid] < a:
            l = mid
        else:
            r = mid
    if l == -1:
        arr.appendleft(a)
    else:
        arr[l] = a
print(len(arr))

<mask token>
input = sys.stdin.readline
<mask token>
N = int(input())
A = [int(input()) for _ in range(N)]
INF = 10 ** 18
arr = deque([])
for a in A:
    l, r = -1, len(arr)
    while r - l > 1:
        mid = (r + l) // 2
        if arr[mid] < a:
            l = mid
        else:
            r = mid
    if l == -1:
        arr.appendleft(a)
    else:
        arr[l] = a
print(len(arr))

import sys
input = sys.stdin.readline
from collections import deque
N = int(input())
A = [int(input()) for _ in range(N)]
INF = 10 ** 18
arr = deque([])
for a in A:
    l, r = -1, len(arr)
    while r - l > 1:
        mid = (r + l) // 2
        if arr[mid] < a:
            l = mid
        else:
            r = mid
    if l == -1:
        arr.appendleft(a)
    else:
        arr[l] = a
print(len(arr))

import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]
INF = 10**18
arr = deque([])
for a in A:
    l, r = -1, len(arr)
    while (r-l) > 1:
        mid = (r+l)//2
        if arr[mid] < a:
            l = mid
        else:
            r = mid
    if l == -1:
        arr.appendleft(a)
    else:
        arr[l] = a
print(len(arr))