#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 50;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n + 2, 0), L(n + 2, 0), R(n + 2, 0);
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = 1;i <= n;i++) L[i] = a[i] > a[i - 1] ? L[i - 1] + 1 : 1;
	for(int i = n;i >= 1;i--) R[i] = a[i] > a[i + 1] ? R[i + 1] + 1 : 1;
	int pos = max_element(L.begin() + 1, L.begin() + n + 1) - L.begin();
	for(int i = 1;i <= n;i++){
        if(i != pos && max(L[i] , R[i]) >= L[pos]){
            cout << "0\n"; return 0;
        }
	}
	if(L[pos] == R[pos] && (L[pos] % 2 != 0)) cout << 1 << endl;
	else cout << "0\n";
	return 0;
}
