#include using namespace std; typedef long long ll; void debug_out(){ cerr << endl; } template void debug_out(Head H, Tail... T){ cerr << ' ' << H; debug_out(T...); } #ifdef local #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 55 #endif typedef pair pii; #define all(x) x.begin(), x.end() int main() { #ifdef local freopen("../in.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int T; cin >> T; while(T--){ int n, k; cin >> n >> k; vector v; for(int i = 0, x; i < n; i++){ cin >> x; v.emplace_back(x - k, x + k); } sort(all(v)); int now = -2e9 - 5, ans = 0; for(auto& e: v){ if(now < e.first) now = e.first, ans++; else if(now < e.second) now++, ans++; } cout << ans << '\n'; } return 0; }