#include #include using namespace std; typedef long long Lint; const int maxn = 1e5 + 10; Lint a[maxn]; void solve() { Lint n, k; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); a[1] -= k; Lint res = 1; for (int i = 2; i <= n; i++) { Lint low = a[i] - k; Lint high = a[i] + k; if (low <= a[i - 1] + 1 && a[i - 1] + 1 <= high) { a[i] = a[i - 1] + 1; res++; } else if (a[i - 1] + 1 < low) { a[i] = low; res++; } else { a[i] = high; } } cout << res << '\n'; } int main() { int T; cin >> T; while (T--) solve(); return 0; }