const input = require('fs').readFileSync('/dev/stdin', 'utf8').slice(0,-1); let [N, X, ...a] = input.split(/\s/); a = a.map(v => +v).sort((a, b) => a - b); X = +X; const binary_search = key => { console.log(key); let ng = -1; let ok = a.length; while (Math.abs(ok - ng) > 1) { mid = ng + (ok - ng) / 2 | 0; if (a[mid] >= key) ok = mid; else ng = mid; } return ok; }; let sum = 0; for (const xx of a) { sum += binary_search(X - xx + 1) - binary_search(X - xx); } console.log(sum);