P6510 Cow Lineup

Description

Under Aunt Xiong’s lead, the cows form a straight line. Obviously, different cows may have different heights. Now the cows want to know: if we pick some consecutive cows, requiring that the leftmost cow $A$ is the shortest, the rightmost cow $B$ is the tallest, and cow $B$ is taller than cow $A$. If there are cows in the middle, then their heights must not be the same as cows $A$ or $B$. What is the maximum number of cows that can be chosen? The cows’ heights are given from left to right. Please output the maximum number of cows that satisfies the conditions (the answer may be $0$ or $2$, but will not be $1$).

Input Format

The first line contains a positive integer $N$, the number of cows. The next $N$ lines each contain a positive integer, where from top to bottom they give the heights $h_i$ of the cows from left to right.

Output Format

Output one integer in a single line, the maximum number of cows.

Explanation/Hint

#### Sample Explanation Choose cows from the $1$st to the $4$th; this satisfies the conditions and is the maximum. #### Constraints For all testdata, $2 \le N \le 10^5$, $1 \le h_i