#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] , pref[MAX] , suff[MAX] ;
int MaxPref[MAX] , MaxSuff[MAX] ;
int n ;

bool check(int x , int y , int a)
{
	return (abs(y - x) >= a) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 1 ; i <= n ; ++i)
		cin>>arr[i] ;
	int now = 0 ;
	for(int i = 1 ; i <= n ; ++i)
	{
		if(arr[i] > arr[i-1])
			pref[i] = pref[i-1] + 1 , now = 1 ;
		else
			pref[i] = 1 , now++ ;
		MaxPref[i] = max({MaxPref[i-1] , pref[i] , now}) ;
	}
	now = 0 ; 
	for(int i = n ; i >= 1 ; --i)
	{
		if(arr[i] > arr[i+1])
			suff[i] = suff[i+1] + 1 , now = 1 ;
		else
			suff[i] = 1 , now++ ;
		MaxSuff[i] = max({MaxSuff[i+1] , suff[i] , now}) ;
	}
	arr[0] = arr[n+1] = 1e9 ;
	int cnt = 0 ;
	for(int i = 1 ; i <= n ; ++i)
	{
		if(arr[i] < arr[i-1] || arr[i] < arr[i+1])
			continue ;
		int y = i + suff[i] - 1 ;
		if((i % 2) == (y % 2))
			y-- ;
		if(check(i , y , pref[i]-1))
			continue ;
		y = i - pref[i] + 1 ;
		if((i % 2) == (y % 2))
			y++ ;
		if(check(i , y , suff[i]-1))
			continue ;
		int a = max(pref[i] , suff[i]) - 1 ;
		int b = max(MaxPref[i - pref[i] + 1] , MaxSuff[i + suff[i] - 1]) - 1 ;
		if(a <= b)
			continue ;
		cnt++ ;
	}
	return cout<<cnt<<"\n" , 0 ;
}		