#include<bits/stdc++.h>
using namespace std;
void solve() {
	long long int n;
	cin>>n;
	long long int arr[n], brr[n], crr[n];
	for(int i=0; i<n; i++)
		cin>>arr[i];
	memset(brr, 0, sizeof(brr));
	memset(crr, 0, sizeof(crr));
	long long int max_peak = 0;
	for(int i=1; i<n; i++)
		if(arr[i]>arr[i-1]) {
			brr[i] = brr[i-1] + 1;
			max_peak = max(max_peak, brr[i]);
		}
	for(int i=n-2; i>=0; i--)
		if(arr[i]>arr[i+1]) {
			crr[i] = crr[i+1] + 1;
			max_peak = max(max_peak, crr[i]);
		}
	long long int max_peak_count=0;
	for(int i=0; i<n; i++) {
		if(brr[i] == max_peak)
			max_peak_count++;
		if(crr[i] == max_peak)
			max_peak_count++;
	}
	if(max_peak_count > 2) {
		cout<<0<<endl;
		return;
	}
	long long int ans=0;
	for(int i=0; i<n; i++)
		if(max_peak == brr[i] && max_peak == crr[i] && max_peak % 2 ==0)
			ans++;
	cout<<ans<<endl;
}
int main() {
	long long int t;
	t=1;
	while (t--)
		solve();
	return 0;
}