A numeric sequence ai is called ordered if a1≤a2≤⋯≤aN. For a given sequence (a1,a2,…,aN), a subsequence is any sequence (ai1,ai2,…,aiK) with 1≤i1<i2<⋯<iK≤N.
For example, the sequence (1,7,3,5,9,4,8) has ordered subsequences such as (1,7) and (3,4,8). All of its longest ordered subsequences have length 4, for example (1,3,5,8).
Given the sequence, find the length of its longest ordered subsequence.
The first line contains the length of the sequence N (1≤N≤1000). The second line contains N integers — the elements of the sequence, each in the range from 0 to 10000, separated by spaces.
Print a single integer: the length of the longest ordered subsequence of the given sequence.