#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int arr[n];
    int index[n];

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

    for (int i = 0 ; i < n ; i++)
    {
        index[i] = i;
    }
    
    for (int i = 0 ; i < n-1 ; i++)
    {
        for (int j = 0 ; j < n-i-1; j++)
        {
            if ( arr[j] > arr[j+1])
            {
                int s = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = s;
                int indeks = index[j];
                index[j] = index[j+1];
                index[j+1] = indeks;
            }
        }
    }

    cout << abs(index[n-1] - index[n-2]);

    return 0;
}