p02317 Longest Increasing Subsequence
For a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A.

An increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≤ i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.

Constraints

* 1 ≤ n ≤ 100000
* 0 ≤ ai ≤ 109

Input


n
a0
a1
:
an-1



In the first line, an integer n is given. In the next n lines, elements of A are given.

Output

The length of the longest increasing subsequence of A.

Examples

Input

5
5
1
3
2
4


Output

3


Input

3
1
1
1


Output

1
```python
N = int(input())
A = [int(input()) for _ in range(N)]
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
def solve(N,A):
    lis = []
    for i in range(N):
        ind = bisect_left(lis,A[i])
        if ind == len(lis):
            lis.append(A[i])
        else:
            lis[ind] = A[i]
    ans = len(lis)
    return ans
print(solve(N,A))


```