// Problem: B. Let's Go Hiking
// Contest: Codeforces - Codeforces Round #706 (Div. 1)
// URL: https://codeforces.com/contest/1495/problem/B
// Author: Pawan Raj (PR_0202)
// Comments: 

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long
#define F(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end()
#define show(A) for (auto i: A) cout << i << " "; cout << '\n';
#define show_(A, n) F(i, n) { show(A[i]) }

using namespace std;
using ld = long double;
using vi = vector < int > ;
using mi = map < int, int > ;
using pi = pair < int, int > ;

const int N = 100005;
const int MOD = 1e9 + 7;
const int inf = 1e18 + 1;
/***************************code begins here*****************************/

void solve() {
    int n, ans = 0; cin >> n;
    vi a(n);
    F(i, n) cin >> a[i];
    
    int pref[n];
    int suff[n];
    
    int c = 1;
    pref[0] = 1;
    for(int i=1;i<n;i++){
    	if(a[i] > a[i-1]) c++;
    	else{
    		c = 1;
    	}
    	pref[i] = c;
    }
    c=1;
    suff[n-1] = 1;
    for(int i=n-2;i>=0;i--){
    	if(a[i] > a[i+1]) c++;
    	else{
    		c = 1;
    	}
    	suff[i] = c;
    }
	int mx = max(*max_element(pref,pref+n),*max_element(suff,suff+n));
	c = 0;
	for(int i= 1;i<n-1;i++){
		if(max(pref[i],suff[i])==mx){
			c ++;
			if(pref[i] == suff[i]){
				if(mx%2)
					ans ++;
			}
		}
	}
	
	if(max(pref[0],suff[0]) == mx ) c ++;
	if(max(pref[n-1],suff[n-1]) == mx ) c ++;
	
	if(c > 1) ans = 0;
	
	cout << ans << '\n';
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}