#include<iostream>
using namespace std;
int main(){
    long long n, lokmaxCount = 0, prevLokmaxIndex = 0, otgovor = 0;
    cin >> n;
    long long vhod[n];
    for(long long i = 0; i < n; i++){
        cin >> vhod[i];
        if(i > 1 &&  i < n - 1){
            if(vhod[i] < vhod[i - 1] && vhod[i - 1] > vhod[i - 2]){
                lokmaxCount++;
                if(lokmaxCount == 1){
                    prevLokmaxIndex = i - 1;
                }else{
                    otgovor = (i - 1) - prevLokmaxIndex;
                    prevLokmaxIndex = i - 1;
                }
            }
        }
    }
    cout << otgovor;
    return 0;
}
