#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF 1e9 #define PI acos(-1) typedef long long ll; typedef pair p_ii; int main() { int i, n, x; cin >> n >> x; vectora(n+1); a[0] = -INF; for (i = 1; i < n+1; i++)cin >> a[i]; sort(a.begin(), a.end()); ll ans = 0; for (i = 1; i < n + 1; i++) { int left = 0, right = n + 1; while (right - left > 1) { int mid = (left + right) / 2; if (a[mid] + a[i] < x)left = mid; else right = mid; } int left2 = 0, right2 = n + 1; while (right2 - left2 > 1) { int mid = (left2 + right2) / 2; if (a[mid] + a[i] <= x)left2 = mid; else right2 = mid; } ans += (ll)left2 - left; } cout << ans << endl; return 0; }