#include <bits/stdc++.h>
#define debug(x) cout << #x << " is " << x << '\n';
#define stigao() cout << "Stigao" < < < '\n';
#define file() freopen("output.txt", "w", stdout);

using namespace std;

typedef long long ll;

const ll MAXI = 9223372036854775807;

bool mat[101][101];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;

    ll a[n + 1];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    ll res = MAXI, white, black, cnt;
    for(int mask = 0; mask < (1 << n); mask++){
        memset(mat, 0, sizeof(mat));
        for(int i = 0; i < n; i++){
            if(mask & (1 << i)){
                for(int k = 0; k < a[i]; k++)
                    mat[i][k] = true;
            } else {
                for(int k = a[i]; k < m; k++)
                    mat[i][k] = true;
            }
        }
        cnt = 0;
        for(int i = 0; i < m; i++){
            white = black = 0;
            for(int j = 0; j < n; j++){
                if(mat[j][i])
                    white++;
                else
                    black++;
            }
            cnt += (white * black);
        }
        res = min(res, cnt);
    }
    cout << res;
}