#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int maxn = 4e5+7 ;
const ll mod = 1000000007;

#define mst(x, a) memset( x,a,sizeof(x) )
#define rep(i, a, b) for(int i=(a);i<=(b);++i)
#define dep(i, a, b) for(int i=(a);i>=(b);--i)

inline ll read() {
	ll x = 0;
	bool f = 0;
	char ch = getchar();
	while (ch < '0' || '9' < ch)
		f |= ch == '-', ch = getchar();
	while ('0' <= ch && ch <= '9')
		x = x * 10 + ch - '0', ch = getchar();
	return f ? -x : x;
}

void out(ll x) {
	int stackk[20];
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (!x) {
		putchar('0');
		return;
	}
	int top = 0;
	while (x)
		stackk[++top] = x % 10, x /= 10;
	while (top)
		putchar(stackk[top--] + '0');
}

int n,a[maxn],pre[maxn],suf[maxn],mx;
int main() {
	n=read();
	rep(i,1,n) a[i] = read(),pre[i] = suf[i] = 1;
	rep(i,2,n)  if(a[i]>a[i-1])   pre[i] = pre[i-1]+1,mx = max(mx,pre[i]);
	dep(i,n-1,1) if(a[i]>a[i+1])  suf[i] = suf[i+1]+1,mx = max(mx,suf[i]);

	int flag=1;
	int cnt=0;
	for(int i=1 ; i<=n ; i++) if(pre[i]==mx) cnt++;
	if(cnt>=2) flag=0;
	cnt=0;
	for(int i=1 ; i<=n ; i++) if(suf[i]==mx) cnt++;
	if(cnt>=2) flag=0;

	if(flag==0) {
		out(0);
		return 0;
	}

	for(int i=1 ; i<=n ; i++) {
		if(pre[i]==suf[i]&&pre[i]==mx&&pre[i]%2) {
			out(1);
			return 0;
		}
	}

	out(0);

	return 0;

}
/*


*/
