#P12127. Elite Squad Selection
Elite Squad Selection
Elite Squad Selection
In the Kingdom of Lanqiao, a team of warriors is arranged in a fixed order. The team consists of \(n\) warriors, each with a strength value \(a_1, a_2, \dots, a_n\).
The king has issued an order to select an elite squad from the team. The squad must satisfy the following conditions:
- The squad members must be chosen while preserving the original order of the warriors.
- The strength of the first and the last warrior of the squad must be strictly greater than the strength of every other warrior in the squad.
The strength of a squad is directly proportional to the number of its members; that is, the more members the squad has, the stronger it is. Help the king determine the maximum possible number of members in an elite squad.
Note: A single warrior is always considered a valid squad.
inputFormat
The input consists of two lines:
- The first line contains an integer \(n\) \( (1 \leq n \leq 10^3)\) representing the number of warriors.
- The second line contains \(n\) space-separated integers \(a_1, a_2, \dots, a_n\), each representing the strength of a warrior.
outputFormat
Output a single integer, which is the maximum number of members in an elite squad that can be formed under the given conditions.
sample
3
1 2 3
2