#include<iostream>
using namespace std;
int main()
{
    int a[19];bool y=false;
    int b=0,N=0,c=1,d=0,minalmaksimum=0,malraz=1000000000;
    cin>>N;if(a[c]==0){cout<<0;}
    while(b!=N)
    {
        cin>>a[b];
 b=b+1;   }

    while(a[c]!=0)
    {
        if(a[c]>a[c-1] and a[c]>a[c+1])
        {
            if(minalmaksimum!=0)
            {
                if(c-d<malraz){

                    malraz=c-d;y=true;

                }
            }
          minalmaksimum=a[c];     d=c;

        }
   c=c+1; }
if(y==true){cout<<malraz-1;}else{cout<<0;}}
    return 0;
}
