#include <bits/stdc++.h>
using namespace std;
#define bye ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ll int
#define pb push_back
#define pf push_front
//#define mp make_pair
#define Mod (int)(998244353)
#define MOD (int)(1e9+7)
#define matrix vector<vector<int> >

ll n,k;
vector<ll>ans;
ll a[200200];
vector<pair<ll,ll> >p;
ll cnt[200200];
ll cnt2[200200];
vector<pair<ll,ll> >ca;
int main()
{
    bye
    int Ti=1;
    //cin >> Ti;
    //scanf("%d",&Ti);
    while(Ti--)
    {

        cin >> n;
        for(int i=0;i<n;i++){
            cin >> a[i];
            p.pb({a[i],i});
        }
        ll mx = 1;
        sort(p.begin(),p.begin()+n);
        for(int i=0;i<n;i++)
            cnt[i]=1;
        for(int i=1;i<n;i++){
            if(a[i]>a[i-1])
                cnt[i]+=cnt[i-1];
            mx = max(mx,cnt[i]);
        }
        for(int i=0;i<n;i++)
            cnt2[i]=1;
        for(int i=n-2;i>=0;i--){
            if(a[i]>a[i+1])
                cnt2[i]+=cnt2[i+1];
            mx = max(mx,cnt2[i]);
        }
        ll c = 0;
        for(int i=0;i<n;i++){
            if(cnt[i]==mx)
                c++;
            if(cnt2[i]==mx)
                c++;
        }
        if(c!=2||mx%2==0)
            cout<< 0 << endl;
        else{
            c=0;
            for(int i=1;i<n-1;i++){
                if(cnt[i]==mx&&cnt2[i]==mx)
                    c=1;
            }
        cout << c << endl;
        }
        ca.clear();
        p.clear();
    }
    return 0;
}
