#include <iostream>
#include <string>

using namespace std;

int main()
{

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

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

    int max1;
    int index1;
    if (max == arr[0])
    {
        max1 = arr[1];
        index1 = 1;
        for (int i = 0 ; i < n ; i++)
        {
            if (arr[i] > max1 && arr[i] != max  )
            {
                max1 = arr[i] ;
                index1 = i;
            }
        }
    }
    else
    {
        max1 = arr[0];
        index1 = 0;
    
        for (int i = 0 ; i < n ; i++)
        {
            if (arr[i] > max1 && arr[i] != max  )
            {
                max1 = arr[i] ;
                index1 = i;
            }
        }
    }

    cout << abs (index - index1);
    

    return 0;
}