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

long numbersLine[100001];
vector<int> localIndexses;

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

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

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

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

    if(zeroIndex==0)
    {
        zeroIndex=sizeLine;
    }

    int nowSize;
    int minSize=1000001;
    int counterLocalNumbers=0;

    for(int index=1; index<zeroIndex; index++)
    {
        if(numbersLine[index]>=numbersLine[index-1] && numbersLine[index]>=numbersLine[index+1])
        {
            counterLocalNumbers++;
            localIndexses.push_back(index);
        }
    }

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

    for(int index=1; index<localIndexses.size(); index++)
    {
        nowSize=localIndexses[index]-localIndexses[index-1]-1;
        minSize=min(minSize, nowSize);
    }

    cout << minSize;
    return 0;
}
