LogiQuest

409. Longest Mountain

MediumTwo PointersDP

A mountain is a contiguous subarray of length ≥ 3 that strictly increases and then strictly decreases. Print the length of the longest mountain, or 0.

Input format

Line 1: n Line 2: n integers

Output format

The longest mountain length.

Example 1

Input

7
2 1 4 7 3 2 5

Output

5

Example 2

Input

3
2 2 2

Output

0

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…