Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/minmax-32-min-va-max-orasidagi-masofa

Distance between the first minimum and maximum

Easy 1000 ms 128 MB 26%
Share

A positive integer $N$ and $N$ integers are given. Let $p$ be the position (indexed from $1$) of the first smallest element and $q$ the position of the first largest element. Find $|p - q|$.

The distance between the first smallest and the first largest elements

Input

The first line contains a positive integer $N$. The next line contains $N$ integers $A_{i}$.

Output

One integer.

Note

$1 \le N \le 1000$
$-10^{9} \le A_{i} \le 10^{9}$

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.