#include #define For(i,l,r) for (register int i=l; i<=r; i++) using namespace std; typedef unsigned long long LL; typedef signed long long ll; template inline void read(T &x) { char c = getchar(); int w = 1; x = 0; while (!isdigit(c)) (c == '-') && (w = -w), c = getchar(); while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar(); x *= w; } const int N = 100010; ll T, n, k, a[N], ans = 0; signed main() { read(T); while (T -- > 0) { read(n); read(k); for (register int i=1; i<=n; ++i) { read(a[i]); } std :: sort(a + 1, a + n + 1); ll last = -1000000000; ans = 0; for (register int i=1; i<=n; ++i) { if (a[i]-k > last) { ans += k * 2 + 1; last = a[i] + k; } else { ans += a[i]+k-last; last = a[i] + k; } } printf("%lld\n", min(ans, n)); } getchar(); return 0; }