#include <iostream>
#include <vector>
using namespace std;

const int DOWN = 0;
const int UP = 1;

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    vector<long long> nA = A;

    int res = 1<<29;
    for (int iter = 0; iter < 2; ++iter) {
        A = nA;
        int cur = DOWN;
        if (iter == 1) cur = UP;
        int con = 0;
        for (int i = 0; i + 1 < N; ++i) {
            if (cur == DOWN) {
                if (A[i] < A[i+1]) {
                    if (i + 2 < N && A[i+1] > A[i+2] && A[i] > A[i+2]) {
                        ++con;
                        ++i;
                        swap(A[i], A[i+1]);
                        cur = 1 - cur;
                        //cout << iter << ", " << i << ";; " << A[i] << ", " << A[i+1] << endl;
                    }
                    else {
                        ++con;
                        swap(A[i], A[i+1]);
                        //cout << iter << ", " << i << ";; " << A[i] << ", " << A[i+1] << endl;
                    }
                }
            }
            else {
                if (A[i] > A[i+1]) {
                    if (i + 2 < N && A[i+1] < A[i+2] && A[i] < A[i+2]) {
                        ++con;
                        ++i;
                        swap(A[i], A[i+1]);
                        cur = 1 - cur;
                        //cout << iter << ", " << i << ";; " << A[i] << ", " << A[i+1] << endl;
                    }
                    else {
                        ++con;
                        swap(A[i], A[i+1]);
                        //cout << iter << ", " << i << ";; " << A[i] << ", " << A[i+1] << endl;
                    }
                }
            }
            cur = 1 - cur;
        }
        res = min(res, con);
    }
    cout << res << endl;
}

