#include <iostream>
using namespace std;
int main ()
{
    int N;
    long long masvyv[10000];
    long long mas[10000];
    cin >> N;
    int k = 0;
    bool vyv = true;
    int i = 0;
    for (i = 0; i < N; i++)
    {
        cin >> masvyv[i];
        if (masvyv[i] != 0 and vyv == true)
        {
            mas[k] = masvyv[i];
            k++;
        }
        else
        {
            mas[k] = masvyv[i];
            vyv = false;
        }
    }
    i = 1;
    int index = 0, preindex = 0;
    int minrai;
    int br;
    do
    {
        if (mas[i] > mas[i-1] and mas[i] > mas[i+1])
        {
            if (br == 1)
            {
                preindex = index;
                index = i;
                minrai = index - preindex -1;
                br++;
            }
            else
            {
                if (br == 0)
                {
                    index = i;
                    br++;
                }
                else
                {
                    preindex = index;
                    index = i;
                    if (index - preindex - 1 < minrai)
                    {
                        minrai=index - preindex - 1;
                    }
                }
            }
            i++;
        }
        else
        {
            i++;
        }
    }
    while (i < k);
    if (preindex == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << minrai << endl;
    return 0;
}

