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