#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, preindex = 0;
    int raz, minraz;
    int br = 0;
    do
    {
        if (mas[z] > mas[z-1] and mas[z] > mas[z+1])
        {
            if (br == 1)
            {
                preindex = index;
                index = z;
                minraz = index - preindex -1;
                br++;
            }
            else
            {
                if (br == 0)
                {
                    index = z;
                    br++;
                }
                else
                {
                    preindex = index;
                    index = z;
                    raz = index-preindex-1;
                    if (raz < minraz)
                    {
                        minraz=raz;
                    }
                }
            }
            z++;
        }
        else
        {
            z++;
        }
    }
    while (z < k);
    if (preindex == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << minraz << endl;
    return 0;
}

