#include <bits/stdc++.h>
#define i64 long long
#define sz(a) int ((a).size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using namespace std;
const int inf32 = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3f;

const int N = 1e5;
int n, a[N], up[N], dw[N];
int mx[3], tx[3];

void insert(int p, int x) {
	rep(i, 0, 3) {
		if (x > mx[i]) {
			per(j, i + 1, 3) {
				mx[j] = mx[j - 1];
				tx[j] = tx[j - 1];
			}
			mx[i] = x;
			tx[i] = p;
			return;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	rep(i, 0, n) cin >> a[i], --a[i];
	up[0] = dw[0] = 1;
	rep(i, 1, n) {
		if (a[i] > a[i - 1]) {
			up[i] = up[i - 1] + 1;
			dw[i] = 1;
		} else {
			dw[i] = dw[i - 1] + 1;
			up[i] = 1;
		}
	}
	rep(i, 0, 3) tx[i] = -1;
	rep(i, 0, n) {
		insert(i, up[i]);
		insert(i - dw[i] + 1, dw[i]);
	}
	if (tx[0] != tx[1]) mx[2] = mx[1];
	if (mx[2] == mx[0]) cout << 0 << '\n';
	else {
		bool res = true;
		rep(i, mx[1], mx[0] + 1) {
			if (not (i & 1))
				res = false;
		}
		cout << res << '\n';
	}
	return 0;
}

/*
	* Read Carefully! Multiple cases? Data range?
	* Transformation? Special cases? Brute & Regularities?
	* Don't get stuck! New directions! Record thoughts!
	* Int overflow? Array bounds? N = 1?
*/
