#include <iostream>
#include <cmath>

using namespace std;

int a[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, idx = -1;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];

        if (a[i] == 0 && idx == -1)
        {
            idx = i;
        }
    }

    a[N] = a[N - 1];

    if (idx == -1)
    {
        idx = N - 1;
    }

    int lok = 0;
    int prev = -1, minDist = 100001;

    for (int i = 1; i < idx; i++)
    {
        if (a[i - 1] < a[i] && a[i] > a[i + 1])
        {
            lok++;

            if (lok == 1)
            {
                prev = i;
            }
            else
            {
                minDist = min(minDist, abs(prev - i) - 1);
                prev = i;
            }
        }
    }


    if (lok <= 1)
    {
        cout << 0;
    }
    else
    {
        cout << minDist;
    }

    cout << endl;

    return 0;
}
/**
7
1 3 -1 5 0 7 4
----
6
1 3 -1 0 7 4
----
11
1 3 -1 2 4 6 -5 1 7
4 0
**/
