The Ascending Mountain PathHard

The Ascending Mountain Path

Hard+30 XP · +10 Aura (late, half)dynamic programminglongest pathsegment tree

Priya is hiking in the Himalayas and wants to find the longest path on a map represented as a sequence of mountain peaks. Each peak has a specific altitude. A path can only go from peak i to peak j if j > i and the altitude of peak j is strictly greater than the altitude of peak i. Priya wants to find the maximum number of peaks she can visit in a single valid path.

Given the altitudes of n peaks in order, find the length of the longest ascending mountain path.

Input

The first line contains an integer n, the number of peaks. The second line contains n space-separated integers representing the altitudes of the peaks, a_1, a_2, ..., a_n.

Output

Print a single integer: the length of the longest ascending mountain path.

Constraints

1 <= n <= 200000 1 <= a_i <= 10^9

Time limit 1 s (native code; slower languages get more)Memory 256 MB15 hidden tests

Example 1

Input
5
1 3 2 4 5
Output
4

The longest path is 1 -> 3 -> 4 -> 5, with length 4.

Example 2

Input
7
10 9 8 7 6 5 4
Output
1

All paths have length 1 as the sequence is strictly decreasing.

Hints