import bisect;n,a,l=int(eval(input())),[-int(eval(input()))],1

for i in range(n-1):

  b=-int(eval(input()))

  if a[-1]>b:a[bisect.bisect_right(a,b)]=b

  else:a.append(b);l+=1

print(l)
n=int(eval(input()))

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

dp=[2]*(n+1)

from bisect import bisect_left,bisect_right

for i in a:

  dp[bisect_left(dp,-i+1)]=-i

print((dp.index(2)))
import bisect

n, a, l = int(eval(input())), [-int(eval(input()))], 1
for i in range(n - 1):
    b = -int(eval(input()))
    if a[-1] > b:
        a[bisect.bisect_right(a, b)] = b
    else:
        a.append(b)
        l += 1
print(l)

n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
dp = [2] * (n + 1)
from bisect import bisect_left, bisect_right

for i in a:
    dp[bisect_left(dp, -i + 1)] = -i
print((dp.index(2)))

-import bisect +n = int(eval(input())) +a = [int(eval(input())) for _ in range(n)] +dp = [2] * (n + 1) +from bisect import bisect_left, bisect_right -n, a, l = int(eval(input())), [-int(eval(input()))], 1 -for i in range(n - 1): -    b = -int(eval(input())) -    if a[-1] > b: -        a[bisect.bisect_right(a, b)] = b -    else: -        a.append(b) -        l += 1 -print(l) +for i in a: +    dp[bisect_left(dp, -i + 1)] = -i +print((dp.index(2)))