#include <iostream>
using namespace std;
int main ()
{
    int N;
    long long masvyv[100];
    long long mas[100];
    cin >> N;
    int k = 0;
    bool vyv = true;
    for (int 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;
        }
    }
    int z = 1;
    int index = 0;
    int raz, minraz;
    do
    {
        if (mas[z] > mas[z-1] and mas[z] > mas[z+1])
        {
            index = z;
            z = k-1;
        }
        else
        {
            z++;
        }
    }
    while (z < k);
    if (index == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    int preindex;
    for (int i = z+1; i < k; i++)
    {
        if (mas[i] > mas[i-1] and mas[i] > mas[i+1])
        {
            preindex = index;
            index = i;
            minraz = index-preindex-1;
            i = k-1;
        }
    }
    for (int i = index+1; i < k; i++)
    {
        if (mas[i] > mas[i-1] and mas[i] > mas[i+1])
        {
            preindex = index;
            index = i;
            raz = index-preindex-1;
            if (raz < minraz)
            {
                minraz=raz;
            }
        }
    }
    cout << minraz << endl;
    return 0;
}
