#include <iostream>
using namespace std;

int main()
{
    int n, mas[100], br=0, min_len, pos1, pos2;
    bool ima_li_0=false;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>mas[i];
    }
    for(int i=1; i<n-1; i++){
        if(mas[i]==0){
            ima_li_0=true;
        }
        if(mas[i-1]<mas[i] && mas[i]>mas[i+1]){
            if(br==0) pos1=i+1;
            if(br==1){
                pos2=i+1;
                if(!ima_li_0) min_len=pos2-pos1-1;
                if(ima_li_0)  min_len=0;
            }
            if(br>1){
                pos1=pos2;
                pos2=i+1;
                if(!ima_li_0){
                    if(pos2-pos1-1<min_len) min_len=pos2-pos1-1;
                }
                if(ima_li_0) min_len=0;
            }
            br++;
            ima_li_0=false;
        }
    }
    if(br==0 || br==1) cout<<"0"<<endl;
    else cout<<min_len<<endl;
    return 0;
}
