//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#define ll long long
#define ld long double
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;
int a[maxn];

vector<pii> v;
//multiset<int> se;
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) cin >> a[i];
	int cur = 0, type = 1;

	int ma = 0, mc = 0;
	for (int i = 0;i < n - 1;i++) {
		if (type == (a[i] < a[i + 1])) {
			cur++;
		} else {
			if (cur != 0) {
				v.push_back(make_pair(cur, type));
				ma = max(cur, ma);
				//se.insert(cur);
			}
			type ^= 1;
			cur = 1;
		}
	}
	if (cur != 0) {
		v.push_back(make_pair(cur, type));
		ma = max(cur, ma);
		//se.insert(cur);
	}
	for (int i = 0;i < v.size();i++) mc += v[i].ff == ma ? 1 : 0;
	int st = v[0].ss == 1 ? 0 : 1;
	int ans = 0;
	for (int i = st;i < v.size() - 1;i+=2) {
		if (v[i].ff == v[i + 1].ff && v[i].ff % 2 == 0) {
			if (mc - (v[i].ff == ma ? 2 : 0) == 0) {
				ans++;
			}
		}
	}
	cout << ans << "\n";
}
