#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

namespace stream {
    template<class T>
    class Stream {
        std::vector<T> instance;
    public:

        Stream(const std::vector<T> &instance) : instance(instance) {}


        template<class F>
        auto filter(const F &func) {
            return filterPrivate([&](const T &t, int &idx) { return func(t); });
        }

        template<class F>
        auto filterWithIndex(const F &func) {
            return filterPrivate(func);
        }

        template<class F>
        auto map(const F &func) {
            return mapPrivate([&](const T &t, int &idx) { return func(t); });
        }

        template<class F>
        auto mapWithIndex(const F &func) {
            return mapPrivate(func);
        }

        template<class F, class R>
        R reduce(const F &func, const R &init_value) {
            R ans = init_value;
            for (int i = 0; i < instance.size(); i++) {
                ans = func(ans, instance[i]);
            }
            return ans;
        }

        template<class F>
        Stream<T> sort(F cmp) {
            std::vector<T> v = instance;
            std::sort(v.begin(), v.end(), cmp);
            return Stream<T>(v);
        }

        Stream<T> sort() {
            std::vector<T> v = instance;
            std::sort(v.begin(), v.end());
            return Stream<T>(v);
        }

        Stream<T> sort_reversed() {
            std::vector<T> v = instance;
            std::sort(v.rbegin(), v.rend());
            return Stream<T>(v);
        }

        Stream<T> unique() {
            std::unordered_set<T> existing;
            std::vector<T> ans;
            for (auto &&i : instance) {
                if (existing.count(i)) { continue; }
                existing.insert(i);
                ans.push_back(i);
            }
            return Stream<T>(ans);
        }

        unsigned long count() {
            return instance.size();
        }

        T sum() {
            return std::accumulate(instance.begin(), instance.end(), T());
        }

        std::vector<T> collect() {
            return instance;
        }

        std::set<T> toSet() {
            return std::set<T>(instance.begin(), instance.end());
        }

    private:
        template<class F>
        Stream<T> filterPrivate(const F &func) {
            std::vector<T> ans;

            for (int i = 0; i < instance.size(); i++) {
                if (func(instance[i], i)) {
                    ans.push_back(instance[i]);
                }
            }
            return Stream<T>(ans);
        }

        template<class F>
        auto mapPrivate(const F &func) {
            using R = typename std::result_of<F(T, int)>::type;
            std::vector<R> ans;
            for (int i = 0; i < instance.size(); i++) {
                ans.push_back(func(instance[i], i));
            }
            return Stream<R>(ans);
        }

    };

    template<class T>
    Stream<T> _(const std::vector<T> &instance) {
        return Stream<T>(instance);
    };

    template<class T>
    Stream<T> _(const std::set<T> &instance) {
        return Stream<T>(std::vector<T>(instance.begin(), instance.end()));
    };

    template<class T, class U>
    Stream<std::pair<T, U>> _(const std::vector<T> &a, std::vector<U> &b) {
        const unsigned long &size = std::min(a.size(), b.size());
        std::vector<std::pair<T, U>> zipped;
        return _(zipped);
    }

    Stream<int> range(int a, int b) {
        if (a >= b) return Stream<int>(std::vector<int>());
        std::vector<int> ans(b - a);
        for (int i = 0; i < b - a; i++)
            ans[i] = a + i;
        return Stream<int>(ans);
    }

    Stream<int> range(int n) {
        return range(0, n);
    }
}

namespace io {
    template<class T>
    void read(std::vector<T> &v) {
        for (int i = 0; i < v.size(); i++) std::cin >> v[i];
    }

    std::vector<int> readIntArray(int n) {
        std::vector<int> a(n);
        read(a);
        return a;
    }

    long long readLong() {
        long long x;
        std::cin >> x;
        return x;
    }

    int readInt() {
        long long x = readLong();
        assert(x >= INT_MIN && x <= INT_MAX);
        return (int) x;
    }

    std::string readWord() {
        std::string x;
        std::cin >> x;
    }

    template<class T>
    void output(const std::vector<T> &v, char delimiter = ' ') {
        if (v.size() > 0) {
            std::cout << v[0];
            for (int i = 1; i < v.size(); i++) {
                std::cout << delimiter << v[i];
            }
        }
        std::cout << std::endl;
    }

    template<class T>
    void output(const T &v) {
        std::cout << v << std::endl;
    }

    void output(double x) {
        printf("%.10lf\n", x);
    }
};

using namespace std;
using namespace stream;
using namespace io;


int main() {
    int n;
    cin >> n;
    auto a = readIntArray(n);
    auto b = a;

    int ans = 12345678;
    for (int p = 0; p < 2; p++) {
        a = b;
        int subAns = 0;
        for (int i = 0; i + 1 < n; i++) {
            if ((a[i] > a[i + 1]) != (i % 2 == p)) {
//                cout << "from:";
//                output(a);
                if (i + 2 < n && (a[i] > a[i + 2]) == (i % 2 == p)) {
                    swap(a[i + 1], a[i + 2]);
                } else {
                    swap(a[i], a[i + 1]);
                }
                subAns++;
//                cout << "to  :";
//                output(a);


            }
        }
        ans = min(subAns, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648