~/algor $ cat problems/minmax-18-ekstremallar-orasidagi-sonlar
Numbers between the first and last maximum
Easy
1000 ms
256 MB
27%
A positive integer $N$ and $N$ integers are given. Find the number of elements located between the first and the last occurrences of the largest element (if the maximum occurs only once, print $0$).
Input
The first line contains an integer $N$. The next line contains $N$ integers $A_{i}$.
Output
One integer — the number of elements between them.
Note
$1 \le N \le 1000$
$-10^{9} \le A_{i} \le 10^{9}$
Examples
Input #1
6 4 9 2 5 9 1
Output #1
2
Input #2
4 1 9 3 4
Output #2
0