//
// Created by Anton Gorokhov
//

#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstddef>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <ctime>
#include <unordered_map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld double

using namespace std;

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

struct segtree {
    segtree *l = nullptr, *r = nullptr;
    int val = 0;
    int lb, rb;
    segtree() {}
    segtree(int L, int R, const vector<int> &v) {
        lb = L, rb = R;
        if (lb + 1 == rb) {
            val = v[lb];
        } else {
            int m = (lb + rb) / 2;
            l = new segtree(lb, m, v);
            r = new segtree(m, rb, v);
            val = max(l->val, r->val);
        }
    }
    int get(int L, int R) {
        if (L >= R) return 0;
        if (L >= rb || lb >= R) return 0;
        if (L <= lb && R >= rb) return val;
        return max(l->get(L, R), r->get(L, R));
    }
};

void solve() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    vector<int> dpl(n, 1), dpr(n, 1);
    for (int i = 1; i < n; ++i) {
        if (v[i] > v[i - 1]) {
            dpl[i] = dpl[i - 1] + 1;
        }
    }
    for (int i = n - 2; i >= 0; --i) {
        if (v[i] > v[i + 1]) {
            dpr[i] = dpr[i + 1] + 1;
        }
    }

    int ans = 0;

    vector<int> dp(n);
    for (int i = 0; i < n; ++i) {
        dp[i] = max(dpl[i], dpr[i]);
    }
    segtree *root = new segtree(0, n, dp);

    for (int i = 0; i < n; ++i) {
        if (min(dpl[i], dpr[i]) == 1) continue;
        if (dpl[i] - (dpl[i] % 2 == 0) != dpr[i] - (dpr[i] % 2 == 0)) continue;
        if (max(dpl[i], dpr[i]) % 2 == 0) continue;
        if (max(root->get(0, i), root->get(i + 1, n)) >= max(dpl[i], dpr[i])) continue;
        ans++;
    }
    cout << ans << '\n';
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif
    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}