#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    long long numbers[N];
    for(int i = 0;i < N;i++)
    {
        cin >> numbers[i];
    }
    vector<int> index;
    for(int i = 1;i < N - 1;i++)
    {
        if(numbers[i] == 0)
        {
            break;
        }
        if(numbers[i] > numbers[i - 1] && numbers[i] > numbers[i + 1])
        {
            index.push_back(i);
        }
    }
    if(index.size() == 1 || index.size() == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    int maxi = 100001;
    for(int i = 0;i < index.size() - 1;i++)
    {
        int GG = index[i + 1] - index[i] - 1;
        if(maxi > GG)
        {
            maxi = GG;
        }
    }
    cout << maxi << endl;
    return 0;
}
