#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_studio(false);
    cin.tie(NULL);
    long long n, pr, popr, tek, lastMax = -1, minDist;
    cin>>n;
    minDist = 999999999;
    cin>>popr>>pr;
    for(long long i = 2; i < n; i++){
        cin>>tek;
        if(pr > popr && pr > tek && pr != 0){
            ///cout<<i - 1<<endl;
            if(lastMax == -1){
                lastMax = i - 1;
                ///cout<<"I. lastMax = "<<lastMax<<endl;
            }else{
                minDist = min(minDist, (((i - 2) - (lastMax + 1)) + 1));
                ///cout<<"II. minDist = "<<minDist<<endl;
                lastMax = i - 1;
            }
        }
        if(tek == 0) break;
        long long a = pr;
        pr = tek;
        popr = a;
    }
    if(minDist == 999999999) minDist = 0;
    cout<<minDist<<endl;

}
