#include<stdio.h>
#include<math.h>
#include<iostream>

#define MAX_N 100000

using namespace std;

struct Rng{
    int p;
    int k;
    Rng(){
        p = 0;
        k = 0;
    }
    Rng(int t_p, int t_k){
        p = t_p;
        k = t_k;
    }
};

void ulaz(int a[], int &n, int &m);
int dosadnost(int a[], Rng b[], int n, int m, int k=0);
int izracunaj(Rng b[], int n, int m);

int main(){
    int a[MAX_N];
    Rng b[MAX_N];
    int n;
    int m;
    ulaz(a, n, m);

    cout << dosadnost(a, b, n, m) << endl;

    return 0;
}


void ulaz(int a[], int &n, int &m){
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
}

int dosadnost(int a[], Rng b[], int n, int m, int k){
    if(k==n){
        return izracunaj(b, n, m);
    }
    b[k] = Rng(0, a[k]);

    int d1 = dosadnost(a, b, n, m, k+1);
    if(m!=a[k]){
        b[k] = Rng(m-a[k], m-1);
    }
    else{
        b[k] = Rng(-1,-1);
    }
    int d2 = dosadnost(a, b, n, m, k+1);
    return min(d1, d2);
}

int izracunaj(Rng b[], int n, int m){
    int s = 0;
    int of = 0;
    int neof = 0;
    for(int j=0;j<m;j++){
        of = neof = 0;
        for(int i=0;i<n;i++){
            if(j<=b[i].k && j>=b[i].p){
                of++;
            }
            else{
                neof++;
            }
        }
        s+=of*neof;
    }
    return s;
}