#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int array[N];
    int lokmax[N];
    int numoflokmax = 0;
    int intoflokmax[N];
    int pos = 1;
    for(int i=0; i<N; i++)
    {
        cin>>array[i];
        if(i != 0 && i != 1 && array[i-1]>array[i] && array[i-1]>array[i-2])
        {
            lokmax[i] = 1;
            numoflokmax++;
            intoflokmax[pos] = i;
            pos++;
        }
        else
        {
            lokmax[i] = 0;
        }
        if(array[i] == 0)
        {
            break;
        }
    }
    int mindis = 100000;
    for(int h=1; h<N; h++)
    {
        if(mindis>abs(intoflokmax[h]-intoflokmax[h+1])-1)
        {
            mindis=abs(intoflokmax[h]-intoflokmax[h+1])-1;
        }
    }
    if(numoflokmax < 2)
    {
        cout<<0;
    }
    else
    {
        cout<<mindis;
    }
    return 0;
}
