//
// Created by Michael Kolinsky on 11/03/2021.
//

#define ll long long int
#define vl vector<ll>
#define vvl vector<vl>
#define vs vector<string>

#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

ll decLen(vl &perm, ll start, ll side)
{

	ll res = 1, last = perm[start];

	for (ll i = start + side; i < (ll) perm.size() && i >= 0; i += side)
	{
		if (last > perm[i]) res++;
		else break;
		last = perm[i];
	}

	return res;
}

int main()
{

	ll n;
	cin >> n;
	vl perm(n);

	for (auto &p : perm)
		cin >> p;

	ll peakLen = 0, longest = 0, res = 0, lastL = 0, r, l, longestCnt = 0;

	for (ll i = 0; i < n;)
	{
		r = decLen(perm, i, +1);

		if (i > 0 && perm[i - 1] < perm[i]) l = lastL + 1;
		else
		{
			l = 1;
		}

		if (max(l, r) > longest)
		{
			longest = max(l, r);
			longestCnt = 1;
		} else if (max(l, r) == longest)
			longestCnt++;

		if (l == r)
		{
			if (min(l, r) > peakLen)
			{
				peakLen = min(l, r);
				res = 1;
			} else if (min(l, r) == peakLen)
				res++;
		}

		if (r == 1)
			lastL = l;
		else
			lastL = 1;
		i += r;
	}

	if (lastL > longest)
	{
		longestCnt = 1;
		longest = lastL;
	} else if(lastL == longest) longestCnt++;

	if (longest == peakLen && longestCnt == 1 && peakLen % 2 == 1)
		cout << res << endl;
	else
		cout << 0 << endl;

	return 0;
}
