#BS0000018. Dãy con tăng dài nhất (Increasing Subsequence)

Dãy con tăng dài nhất (Increasing Subsequence)

Increasing Subsequence

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array of nn integers, find the length of the longest strictly increasing subsequence. A subsequence is obtained by deleting some elements without changing the order of the remaining elements.

Input

The first line contains nn.

The second line contains nn integers.

Output

Print the length of the longest strictly increasing subsequence.

Subtasks

  • Subtask 1 — 20%: n≤2000n\le2000.
  • Subtask 2 — 30%: n≤50000n\le50000.
  • Subtask 3 — 50%: 1≤n≤2⋅1051\le n\le2\cdot10^5, 1≤xi≤1091\le x_i\le10^9.

Examples

Input

8
7 3 5 3 6 2 9 8

Output

4

Explanation

For example, 3,5,6,93,5,6,9 is a strictly increasing subsequence of length 44.