Skip to main content
LIVE CONTEST: Round #7 · Begin Marathon is live now! …

~/algor $ cat problems/minmax/numbers-between-the-first-and-last-maximum

Numbers between the first and last maximum

Author Iqbolshoh Ilhomjonov 3 @iqbolshoh 650 problems
Easy 1000 ms 256 MB 27%
Share

A positive integer and 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 ).

The number of elements between the first and the last maximums

Input

The first line contains an integer . The next line contains integers .

Output

One integer — the number of elements between them.

Note


Examples

Input #1
6
4 9 2 5 9 1
Output #1
2
Input #2
4
1 9 3 4
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.