#include "bits/stdc++.h"
#include "cmath"
using namespace std;
#define ios               ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;
const long long mod = 1000000007;

signed main(){
	ios
	int tt = 1;
	//cin >> tt;
	while(tt--){
		int n, ok = 0, points = 0;
		cin >> n;
		vector<int> a(n), b(n), c(n);
		for(int i = 0; i<n; i++) cin >> a[i];
		for(int i = 1; i<n; i++){
			if(a[i]>a[i-1]){
				b[i] = b[i-1]+1;	ok = max(ok, b[i]);
			}
		}
		for(int i = n-2; i>=0; i--){
			if(a[i]>a[i+1]){
				c[i] = c[i+1]+1;    ok = max(ok, c[i]); 
			}
		}
		for(int i = 0; i<n; i++){
			if(ok == b[i]) points++;
			if(ok == c[i]) points++;
		}
		if(points > 2) cout << 0 << endl;
		else{
			int ans = 0;
			for(int i = 0; i<n; i++){
				if(b[i] == ok and c[i] == ok and ok%2 == 0) ans++;
			}
			cout << ans;
		}	 
	}
}

