#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
 
#define F first
#define S second
 
const int MOD = 1e9 + 7;// XXX
const int C = 26;// XXX
 
void add(int &x, int y){
	x += y;
	while (x >= MOD) x -= MOD;
	while (x < 0) x += MOD;
}
 
int fix(int x){
	while (x >= MOD) x -= MOD;
	while (x < 0) x += MOD;
	return x;
}
 
int pw(int a, int b){
	int ret = 1;
	while (b){
		if (b & 1)
			ret = 1ll*ret*a%MOD;
		b >>= 1;
		a = 1ll*a*a%MOD;
	}
	return ret;
}
 
const int MAXN = 1e6 + 10;

#define left fuck
#define right FUCK

int n, p[MAXN], left[MAXN], right[MAXN];

set<array<int,3>> st;
int get() {
	if(st.empty())
		return 0;
	return (*st.rbegin())[0];
}

void solve() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for(int i = 1; i < n; i++) {
		if(p[i] > p[i-1]) {
			left[i] = left[i-1] + 1;
		}
	}
	for(int i = n-2; ~i; --i) {
		if(p[i] > p[i+1]) {
			right[i] = right[i+1] + 1;
		}
	}
	for(int i = 0; i < n; i++) {
		st.insert({left[i], i, 0});
		st.insert({right[i], i, 1});
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int k = min(left[i], right[i]);
		st.erase({left[i], i, 0});
		st.erase({right[i], i, 1});
		
		int maxOther = get();
		int ok = k > 0;
		
		if(maxOther >= max(left[i], right[i])) {
			ok = 0;
		}
		
		if(k % 2 == 1) {
			ok = 0;
		} else {
			// thanks samples
			if(max(left[i], right[i]) % 2 == 1) {
				ok = 0;
			}
			if(max(left[i], right[i]) != k) {
				ok = 0;
			}
		}
		
		if(ok) {
			// cerr << "win at: " << i+1 << "\n";
			++ans;
		}
		st.insert({left[i], i, 0});
		st.insert({right[i], i, 1});
	}
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cout << fixed << setprecision(6);
	
	int te = 1;	
	// cin >> te;
	for (int w = 1; w <= te; w++){
		// cout << "Case #" << w << ": ";
		solve();
	}
	return 0;
}
