#include <iostream>
using namespace std;

int main(){
    int n,br=0;
    cin>>n;
    int tochki[n];
    for(int i=0;i<n;i++){
        cin>>tochki[i];
    }
    for(int i=n/2;i<=n;i++){
            for(int j=0;j<n/2;j++){
                if(tochki[i]<tochki[i+j]){
                    br++;
                }
                if(tochki[i-j]<tochki[i]){
                    br++;
                }
                if(tochki[i]>tochki[i+j]){
                    br++;
                }
                if(tochki[i-j]>tochki[i]){
                    br++;
                }if(tochki[i-j-1]<tochki[i]){
                    br++;
                }if(tochki[i-j-1]>tochki[i]){
                    br++;
                }
                /*
                if(tochki[i]<tochki[i+2]){
                    br++;
                }
                if(tochki[i-2]<tochki[i]){
                    br++;
                }
                if(tochki[i]>tochki[i+2]){
                    br++;
                }
                if(tochki[i-2]>tochki[i]){
                    br++;
                }if(tochki[i]<tochki[i+3]){
                    br++;
                }
                if(tochki[i-3]<tochki[i]){
                    br++;
                }
                if(tochki[i]>tochki[i+3]){
                    br++;
                }
                if(tochki[i-3]>tochki[i]){
                    br++;
                }*/
            }
    }
    cout<<br/2;
    return 0;
}