#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int vhod[n];
    for(int i = 0; i < n; i++){
        cin >> vhod[i];
    }

    int lokmaxCount = 0, prevLokmaxI, otg = n + 1;
    for(int i = 1; i < n - 1; i++){
        if(vhod[i - 1] == 0){
            break;
        }
        if(vhod[i] > vhod[i - 1] && vhod[i] > vhod[i + 1]){
            if(lokmaxCount == 0){

            }else{
                if(otg > i - prevLokmaxI - 1){
                    otg = i - prevLokmaxI - 1;
                }
            }
            prevLokmaxI = i;
            lokmaxCount++;
        }
    }
    if(lokmaxCount > 1){
        cout << otg;
    }else{
        cout << "0";
    }
    return 0;
}
