#include<iostream>
#include<algorithm>
using namespace std;
long long mas[100000];
long long lok[50000];
int main()
{
    long long n, razt = -1, br = 0;

    cin >> n;

    long long nm = n + 10;

    for(long long i = 0; i < n; i++)
    {
        cin >> mas[i];
    }

    for(long long i = 0; i < n; i++)
    {
        lok[i] = -1;
    }

    for(long long i = 1; mas[i] != 0; i++)
    {
        if(mas[i] > mas[i + 1] && mas[i] > mas[i - 1] && i != n - 1)
        {
            lok[br] = i;

            br++;
        }
    }

    if(br == 0 || br == 1)
    {
        cout << 0;
        return 0;
    }
    else
    {
        sort(lok, lok + br);

        for(long long i = 0; i < n - 1; i++)
        {
            if(lok[i + 1] - lok[i] - 1 < nm && lok[i + 1] != -1 && lok[i] != -1)
            {
                nm = lok[i + 1] - lok[i] - 1;
            }
        }
    }

    cout << nm;


    return 0;
}
