cho.sh
Notes
Loading...

Box Nesting

Time limit

2s

Memory limit

128 MB

Problem

There are n cube-shaped boxes arranged in a row from front to back. Each box has a size.

A box may be placed inside a later box only when the earlier box is smaller than the later box. The order of the boxes cannot be rearranged, so the selected box sizes must form a strictly increasing subsequence.

Given the sizes of the boxes, determine the maximum number of boxes that can be nested into one chain.

Input

The first line contains the number of boxes n (1 <= n <= 1000).

The second line contains the sizes of the boxes in order, separated by spaces. Each size is an integer from 1 to 1000.

Output

Print the maximum number of boxes that can be nested into one chain.