#include <bits/stdc++.h>
using namespace std;

int totalLocalSums[100001];
long numbersLine[100001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int sizeLine;
    int counterLocalNumbers=0;
    int zeroIndex;
    int firstIndex;
    cin >> sizeLine;

    for(int index=0; index<sizeLine; index++)
    {
        cin >> numbersLine[index];

        if(numbersLine[index]==0)
        {
            zeroIndex=index;
        }

        if(index>1 && index<=zeroIndex)
        {
            if(numbersLine[index-1]>numbersLine[index] && numbersLine[index-1]>numbersLine[index-2])
            {
                counterLocalNumbers++;
                totalLocalSums[index-1]=totalLocalSums[index-2]+1;

                if(totalLocalSums[index-1]==1 && totalLocalSums[index-2]==0)
                {
                    firstIndex=index-1;
                }
            }
            else
            {
                totalLocalSums[index-1]=totalLocalSums[index-2];
            }
        }
    }

    if(counterLocalNumbers==0 || counterLocalNumbers==1)
    {
        cout << 0;
        return 0;
    }

    int nowSize=0;
    int minSize=100001;

    for(int index=firstIndex+1; index<zeroIndex; index++)
    {
        if(totalLocalSums[index]==totalLocalSums[index-1])
        {
            nowSize++;
        }
        else
        {
            minSize=min(minSize, nowSize);
            nowSize=0;
        }
    }

    cout << minSize;
    return 0;
}
