#include <iostream>
using namespace std;
int main()
{ 
    int n;
    cin >> n;
    int arr[n];

    for ( int i = 0 ; i < n ; i ++ )
    {
        cin >> arr[i];
    }

    int andis1 = 0;
    for ( int i = 1 ; i < n ; i ++ )
    {
        if ( arr[i] > arr[andis1] )
        {
            andis1 = i;
        }
    }

    int andis2;
    if ( andis1 == 0 )
    {
        andis2 = 1;
    }

    else 
    { 
        andis2 = 0;
    }

    for ( int i = 0 ; i < n ; i ++ )
    {
        if ( i != andis1 && arr[i] > arr[andis2] )
        {
            andis2 = i;
        }
    }

    cout << abs(andis1 - andis2);

    return 0;
}