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

~/algor $ cat problems/minmax/distance-between-the-first-minimum-and-maximum

Distance between the first minimum and maximum

Author Iqbolshoh Ilhomjonov 3 @iqbolshoh 650 problems
Easy 1000 ms 128 MB 26%
Share

A positive integer and integers are given. Let be the position (indexed from ) of the first smallest element and the position of the first largest element. Find .

The distance between the first smallest and the first largest elements

Input

The first line contains a positive integer . The next line contains integers .

Output

One integer.

Note


Examples

Input #1
6
4 1 6 8 2 8
Output #1
2
Input #2
1
7
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.