Longest Ordered Subsequence

No attempts yetTime limit1sMemory limit128 MB

Problem

A numeric sequence aia_i is called ordered if a1a2aNa_1 \le a_2 \le \dots \le a_N. For a given sequence (a1,a2,,aN)(a_1, a_2, \dots, a_N), a subsequence is any sequence (ai1,ai2,,aiK)(a_{i_1}, a_{i_2}, \dots, a_{i_K}) with 1i1<i2<<iKN1 \le i_1 < i_2 < \dots < i_K \le N.

For example, the sequence (1,7,3,5,9,4,8)(1, 7, 3, 5, 9, 4, 8) has ordered subsequences such as (1,7)(1, 7) and (3,4,8)(3, 4, 8). All of its longest ordered subsequences have length 4, for example (1,3,5,8)(1, 3, 5, 8).

Given the sequence, find the length of its longest ordered subsequence.

Input

The first line contains the length of the sequence NN (1N10001 \le N \le 1000). The second line contains NN integers — the elements of the sequence, each in the range from 00 to 1000010000, separated by spaces.

Output

Print a single integer: the length of the longest ordered subsequence of the given sequence.