#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    int n;
    int m;
    int a[10];
    int i;
    int j;
    int b;
    int p;
    int s;
    
    cin >> n;
    cin >> m;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (i = 1; i <= n; i++) {
        if (a[i] > (m + 1) / 2) {
            a[i] = m - a[i];
        }
    }
    for (i = 1; i <= n - 1; i++) {
        for (j = i + 1; j <= n; j++) {
            if (a[i] > a[j]) {
                p = a[i];
                a[i] = a[j];
                a[j] = p;
            }
        }
    }
    p = 0;
    s = 0;
    for (b = 0; b <= m / 2; b++) {
        for (i = 1; i <= n; i++) {
            if (a[i] == b) {
                p = p + 1;
            }
        }
        s = s + p * (n - p);
    }
    cout << s << endl;
    return 0;
}