#include <bits/stdc++.h>
using namespace std;
#define si short int
#define ll long long

int main(void)
{
    ll n,m;
    ll puni=0;
    scanf("%lld %lld",&n,&m);
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        scanf("%lld", &a[i]);
        if(a[i]==m) puni++;
        else if(a[i]==0) puni++, a[i]=m;
    }
    sort(a,a+n);
    //for(ll i=0;i<n;i++)
    //    cout<<a[i]<<' ';
    //cout<<endl;
    if(puni==0)
    {
        ll sum=0;
        for(ll i=1;i<=a[n-1];i++)
        {
            ll p=0;
            for(ll j=0;j<n;j++)
                {
                    if(a[j]>=i)
                        p++;
                }
            sum+=p*(n-p);
        }
        printf("%lld",sum);
    }
    else
    {
        ll sum1=0, sum2=0;
        for(ll i=1;i<=a[n-1];i++)
        {
            ll p=0;
            for(ll j=0;j<n;j++)
                {
                    if(a[j]>=i)
                        p++;
                }
            sum1+=p*(n-p);
        }

        for(ll i=0;i<n;i++)
        {
            ll p=0;
            for(ll j=0;j<n;j++)
                if(m-a[j]>i) p++;
            p+=puni;
            //cout<<p<<' '<<puni<<endl;
            sum2+=p*(n-p);//, cout<<sum2<<' ';
        }
        //cout<<endl;
        //cout<<sum1<<' '<<sum2<<endl;
        printf("%lld",min(sum1,sum2));
    }
}