#include<iostream>
using namespace std;

int main () {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int a,b,c;
    cin >> c >> b;
    int dis = -1, sm_dis = -1;
    for (int i = 0; i < n - 2; i++) {
        cin >> a;
        if (dis != - 1) {
            dis++;
        }

        if (b > a && b > c) {
            if (dis == -1) {
                dis = 0;
            } else {
                dis--;
                if (sm_dis == -1) {
                    sm_dis = dis;
                } else {
                    if (dis < sm_dis) {
                        sm_dis = dis;
                    }
                }
                dis = 0;
            }
        }

        if (a == 0) {
            break;
        }

        c = b;
        b = a;
    }
    if (sm_dis == -1) {
        cout << 0;
        return 0;
    }
    cout << sm_dis;
}
