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

long numbersLine[100001];

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

    int sizeLine;
    cin >> sizeLine;

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

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

    for(int index=1; index<sizeLine-1; index++)
    {
        if(numbersLine[index]==0)
        {
            break;
        }

        if(numbersLine[index]>numbersLine[index-1] && numbersLine[index]>numbersLine[index+1])
        {
            counterLocalNumbers++;

            if(lastIndex!=0)
            {
                nowSize=index-lastIndex-1;
                minSize=min(minSize, nowSize);
            }

            lastIndex=index;
        }
    }

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

    cout << minSize;
    return 0;
}
