You want to build a fence that will consist of $n$ equal sections. All sections have a width equal to $1$ and height equal to $k$. You will place all sections in one line side by side.

Unfortunately, the ground beneath the fence is not flat. For simplicity, you can think that the ground level under the $i$-th section is equal to $h_i$.

You should follow several rules to build the fence:

the consecutive sections should have a common side of length at least $1$;

the first and the last sections should stand on the corresponding ground levels;

the sections between may be either on the ground level or higher, but not higher than $k - 1$ from the ground level $h_i$ (the height should be an integer);

One of possible fences (blue color) for the first test case

Is it possible to build a fence that meets all rules?


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The first line of each test case contains two integers $n$ and $k$ ($2 \le n \le 2 \cdot 10^5$; $2 \le k \le 10^8$) — the number of sections in the fence and the height of each section.

The second line of each test case contains $n$ integers $h_1, h_2, \dots, h_n$ ($0 \le h_i \le 10^8$), where $h_i$ is the ground level beneath the $i$-th section.

It's guaranteed that the sum of $n$ over test cases doesn't exceed $2 \cdot 10^5$.


-----Output-----

For each test case print YES if it's possible to build the fence that meets all rules. Otherwise, print NO.

You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answer).


-----Examples-----

Input
3
6 3
0 0 2 5 1 1
2 3
0 2
3 2
3 0 2
Output
YES
YES
NO


-----Note-----

In the first test case, one of the possible fences is shown in the picture.

In the second test case, according to the second rule, you should build both sections on the corresponding ground levels, and since $k = 3$, $h_1 = 0$, and $h_2 = 2$ the first rule is also fulfilled.

In the third test case, according to the second rule, you should build the first section on height $3$ and the third section on height $2$. According to the first rule, the second section should be on the height of at least $2$ (to have a common side with the first section), but according to the third rule, the second section can be built on the height of at most $h_2 + k - 1 = 1$.

Difficulty: MEDIUM_HARD

Solutions:
for _ in range(int(input())):
	(n, h) = map(int, input().split())
	a = list(map(int, input().split()))
	mi = a[0]
	ma = a[0]
	a = a[1:]
	s = 1
	for x in a:
		mi = max(x, mi - h + 1)
		ma = min(x + h - 1, ma + h - 1)
		if ma < mi:
			s = 0
	if mi != a[-1]:
		s = 0
	print('YES') if s == 1 else print('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def testcase(t):
	for pp in range(t):
		solve(pp)

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	y %= p - 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

def solve(case):
	(n, k) = sep()
	h = lis()
	mn = h[0]
	mx = h[0]
	for i in range(1, n):
		mn = max(mn - (k - 1), h[i])
		mx = min(mx + k - 1, h[i] + k - 1)
		if mn > mx:
			break
	if not mn <= h[-1] <= mx:
		print('NO')
		return
	print('YES')
testcase(int(inp()))


from functools import reduce
import os
import sys
from collections import *
from decimal import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	(n, k) = value()
	a = arr()
	mn = a[0]
	mx = a[0] + k
	ans = 'YES'
	for i in range(1, n - 1):
		if a[i] < mn:
			if a[i] + k - 1 + k <= mn:
				ans = 'NO'
				break
			mn = max(a[i], mn - (k - 1))
			mx = a[i] + k - 1 + k
		else:
			if a[i] >= mx:
				ans = 'NO'
				break
			mn = a[i]
			mx = min(a[i] + k - 1, mx - 1) + k
	if a[-1] >= mx or a[-1] + k <= mn:
		ans = 'NO'
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	mn = h[0]
	mx = h[0]
	f = 0
	for i in range(1, n - 1):
		mn = max(h[i], mn - (k - 1))
		mx = min(h[i] + k - 1, mx + k - 1)
		if mn > mx:
			f = 1
	if h[n - 1] < mn - k + 1 or h[n - 1] > mx + k - 1:
		f = 1
	if f == 1:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	ans = 'YES'
	minn = h[0]
	maxx = h[0]
	for i in range(1, n):
		minn = max(h[i], minn - k + 1)
		maxx = min(h[i] + k - 1, maxx + k - 1)
		if maxx < minn or minn + k - 1 < maxx:
			ans = 'NO'
			break
	if minn > h[-1] or h[-1] > maxx:
		ans = 'NO'
	print(ans)


import os
import sys
from io import BytesIO, IOBase
import math as M
import itertools as ITR
from collections import defaultdict as D
from collections import Counter as C
from collections import deque as Q
import threading
from functools import lru_cache, reduce
from functools import cmp_to_key as CMP
from bisect import bisect_left as BL
from bisect import bisect_right as BR
import random as R
import string
import cmath, time
enum = enumerate
start_time = time.time()
MOD = 1000000007
MA = float('inf')
MI = float('-inf')
di8 = ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))
di4 = ((1, 0), (0, 1), (-1, 0), (0, -1))

def increase_stack():
	sys.setrecursionlimit(2 ** 32 // 2 - 1)
	threading.stack_size(1 << 27)

def binary(n):
	return bin(n)[2:]

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def maxfactor(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
	if q:
		return q[-1]

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	l.sort()
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def seive(n):
	a = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	prime[0] = prime[1] = False
	return (a, prime)

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countchar(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def str_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def lis(arr):
	n = len(arr)
	lis = [1] * n
	maximum = 0
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
				maximum = max(maximum, lis[i])
	return maximum

def lcm(arr):
	a = arr[0]
	val = arr[0]
	for i in range(1, len(arr)):
		gcd = gcd(a, arr[i])
		a = arr[i]
		val *= arr[i]
	return val // gcd

def ncr(n, r):
	return M.factorial(n) // (M.factorial(n - r) * M.factorial(r))

def npr(n, r):
	return M.factorial(n) // M.factorial(n - r)

def IF(c, t, f):
	return t if c else f

def YES(c):
	print(IF(c, 'YES', 'NO'))

def Yes(c):
	print(IF(c, 'Yes', 'No'))

def yes(c):
	print(IF(c, 'yes', 'no'))

def JA(a, sep=' '):
	print(sep.join(map(str, a)))

def JAA(a, s='\n', t=' '):
	return s.join((t.join(map(str, b)) for b in a))

def PS(a, s=' '):
	print(str(a), end=s)

def I():
	return int(inp())

def F():
	return float(inp())

def LI():
	return list(map(int, inp().split()))

def LF():
	return list(map(float, inp().split()))

def MATI(n):
	return [LI() for i in range(n)]

def MATS(n):
	return [list(inp()) for i in range(n)]

def IV():
	return map(int, inp().split())

def FV():
	return map(float, inp().split())

def LS():
	return list(inp())

def S():
	return inp()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
inp = lambda : sys.stdin.readline().rstrip('\r\n')
TestCases = 1

def solve():
	(n, k) = IV()
	arr = LI()
	(mi, ma) = (arr[0], arr[0])
	flag = True
	for i in range(1, n):
		mi = max(arr[i], mi - k + 1)
		ma = min(ma + k - 1, arr[i] + k - 1)
		if mi > ma:
			flag = False
		if i == n - 1 and mi != arr[i]:
			flag = False
	YES(flag)

def main():
	flag = 1
	try:
		sys.stdin = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/input.txt', 'r')
		sys.stdout = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/output.txt', 'w')
	except:
		flag = 0
	t = 1
	if TestCases:
		t = I()
	for _ in range(1, t + 1):
		solve()
	if flag:
		print('Time: %.4f sec' % (time.time() - start_time))
		localtime = time.asctime(time.localtime(time.time()))
		print(localtime)
		sys.stdout.close()
main()


import sys
for _ in range(int(input())):
	(n, k) = map(int, sys.stdin.readline().split())
	h = [int(i) for i in sys.stdin.readline().split()]
	flag = 1
	available_interval = [h[0] + 1, h[0] + 1]
	for h_i in h:
		available_interval = [max(h_i + 1, available_interval[0] - k + 1), min(h_i + k + k - 1, available_interval[1] + k - 1)]
		if available_interval[1] - available_interval[0] + 1 < k or available_interval[0] - h_i > k:
			flag = 0
			break
	if flag and available_interval[0] == h[-1] + 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	lst = [0] * n
	lst[0] = h[0]
	for i in range(1, n - 1):
		if h[i] - lst[i - 1] >= k or lst[i - 1] - h[i] > 2 * (k - 1):
			print('NO')
			break
		if h[i + 1] > h[i]:
			lst[i] = min(lst[i - 1] + k - 1, h[i] + k - 1)
		else:
			lst[i] = max(h[i], lst[i - 1] - k + 1)
	else:
		if h[n - 1] - lst[n - 2] >= k or lst[n - 2] - h[n - 1] >= k:
			print('NO')
		else:
			print('YES')


n = int(input())
for i in range(n):
	(n, k) = map(int, input().split())
	nums = list(map(int, input().split()))
	bot = nums[0]
	top = nums[0] + k
	control = 'YES'
	top2 = 0
	for j in range(1, n):
		if j == n - 1:
			top2 = nums[j] + k
		else:
			top2 = nums[j] + 2 * k - 1
		if top2 <= bot or nums[j] >= top:
			control = 'NO'
			break
		bot = max(nums[j], bot - k + 1)
		top = min(top + k - 1, top2)
	print(control)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	minn = [l[0]]
	maxx = [l[0]]
	for i in range(1, n):
		minnn = max(l[i], minn[i - 1] - k + 1)
		maxxx = min(l[i] + k - 1, maxx[i - 1] + k - 1)
		minn.append(minnn)
		maxx.append(maxxx)
	minn1 = [l[n - 1]]
	maxx1 = [l[n - 1]]
	i = n - 1
	j = 0
	while i > 0:
		i -= 1
		j += 1
		minnn = max(l[i], minn1[j - 1] - k + 1)
		maxxx = min(l[i] + k - 1, maxx1[j - 1] + k - 1)
		minn1.append(minnn)
		maxx1.append(maxxx)
	flag = 'YES'
	for i in range(n):
		if minn[i] > maxx[i] or minn1[i] > maxx1[i]:
			flag = 'NO'
			break
	print(flag)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	lo = list(h)
	hi = [i + k - 1 for i in h]
	hi[0] = lo[0]
	hi[n - 1] = lo[n - 1]
	valid = True
	for i in range(1, n):
		a = lo[i - 1] - k + 1
		b = hi[i - 1] + k - 1
		if a > hi[i] or b < lo[i]:
			valid = False
			break
		lo[i] = max(lo[i], a)
		hi[i] = min(hi[i], b)
	for i in range(n - 2, -1, -1):
		a = lo[i + 1] - k + 1
		b = hi[i + 1] + k - 1
		if a > hi[i] or b < lo[i]:
			valid = False
			break
		lo[i] = max(lo[i], a)
		hi[i] = min(hi[i], b)
	print('YES' if valid else 'NO')


def intersection(seg1, seg2):
	if seg1[0] <= seg2[0]:
		if seg1[1] < seg2[0]:
			return False
		elif seg1[1] <= seg2[1]:
			return [seg2[0], seg1[1]]
		else:
			return [seg2[0], seg2[1]]
	elif seg1[0] > seg2[1]:
		return False
	elif seg1[1] >= seg2[1]:
		return [seg1[0], seg2[1]]
	else:
		return [seg1[0], seg1[1]]
cases = int(input())
for _ in range(cases):
	(n, k) = list(map(int, input().split()))
	level = list(map(int, input().split()))
	seg_satis = [0, level[0]]
	seg_need = []
	seg_satis_temp = []
	den = 0
	for i in level[:-1]:
		seg_need = [i, i + k - 1]
		seg_satis_temp = intersection(seg_satis, seg_need)
		if seg_satis_temp == False:
			den = 1
			break
		else:
			seg_satis = [seg_satis_temp[0] - k + 1, seg_satis_temp[1] + k - 1]
	if den == 1:
		print('NO')
	else:
		seg_need = [level[-1], level[-1]]
		seg_satis_temp = intersection(seg_satis, seg_need)
		if seg_satis_temp == False:
			print('NO')
		else:
			print('YES')


for ___ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	hs = list(map(int, input().split()))
	rg = [-2, 10 ** 9]
	ok = True
	for (i, h) in enumerate(hs):
		if i == 0 or i == len(hs) - 1:
			rgn = [h, h + k]
		else:
			rgn = [h, h + k + k - 1]
		rg = [max(0, rg[0] - k + 1), rg[1] + k - 1]
		rg = [max(rg[0], rgn[0]), min(rg[1], rgn[1])]
		if rg[1] - rg[0] < k:
			ok = False
			break
	print('YES' if ok else 'NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	ans = 1
	(lb, ub) = (h[0], h[0])
	for i in range(1, n):
		lb_next = h[i]
		ub_next = h[i] + k - 1
		lb_next = max(lb - (k - 1), lb_next)
		ub_next = min(ub + (k - 1), ub_next)
		if lb_next > ub_next:
			ans = 0
			break
		lb = lb_next
		ub = ub_next
	if lb > h[n - 1] or ub < h[n - 1]:
		ans = 0
	print('YES' if ans else 'NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	(curmx, curmn) = (ar[0], ar[0])
	for i in range(1, n):
		if curmx + (k - 1) < ar[i]:
			print('NO')
			break
		if curmn - (k - 1) > ar[i] + (k - 1):
			print('NO')
			break
		if i == n - 1 and curmn - (k - 1) > ar[i]:
			print('NO')
			break
		curmx = min(curmx + k - 1, ar[i] + k - 1)
		curmn = max(ar[i], curmn - (k - 1))
	else:
		print('YES')


for tc in range(int(input())):
	(n, k) = map(int, input().split())
	ls = [int(x) for x in input().split()]
	(mn, mx) = (ls[0], ls[0])
	for h in ls[1:]:
		(mn, mx) = (max(mn - k + 1, h), min(mx + k - 1, h + k - 1))
		if mn > mx:
			print('NO')
			break
	else:
		if mn <= ls[-1] <= mx:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	mn = h[0]
	mx = h[0]
	b = 0
	for i in range(1, n):
		mn = max(mn + 1 - k, h[i])
		mx = min(h[i] + k - 1, mx - 1 + k)
		if mn > mx:
			print('NO')
			b = 1
			break
	if b == 0:
		if mn == h[-1]:
			print('YES')
		else:
			print('NO')


def buildFence():
	(lowest, highest) = (heights[0], heights[0])
	for i in range(1, n - 1):
		(newLow, newHigh) = (heights[i], heights[i] + k - 1)
		if newHigh + k <= lowest or newLow >= highest + k:
			return False
		newLow += max(0, lowest + 1 - newLow - k)
		newHigh -= max(0, newHigh + 1 - highest - k)
		lowest = newLow
		highest = newHigh
	if lowest - k < heights[-1] < highest + k:
		return True
	else:
		return False
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	heights = list(map(int, input().split()))
	if buildFence():
		print('YES')
	else:
		print('NO')


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = int(1000000000.0) + 7
MAX = int(200000.0) + 1

def solve():
	(n, k) = vars()
	arr = array()
	maxi = arr[0]
	mini = arr[0]
	for i in range(1, n):
		maxi = min(maxi + (k - 1), arr[i] + k - 1)
		mini = max(mini - (k - 1), arr[i])
		if mini > maxi:
			print('NO')
			return
	if arr[-1] != mini:
		print('NO')
	else:
		print('YES')

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)
primes = [1 for i in range(MAX)]

def sieve():
	global primes
	primes[0] = primes[1] = 0
	i = 2
	while i <= MAX ** 0.5:
		j = i * i
		while primes[i] and j < MAX:
			if j % i == 0:
				primes[j] = 0
			j += i
		i += 1

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):

	def __init__(self, file):
		self.newlines = 0
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def S():
	return input().strip()

def print_list(l):
	print(' '.join(map(str, l)))

def judge():
	(n, k) = RL()
	a = RLL()
	(low, high) = (a[0], a[0])
	for v in a[1:]:
		(low, high) = (max(low - k + 1, v), min(high + k - 1, v + k - 1))
		if low > high:
			return False
	return low <= a[-1] <= high
for _ in range(N()):
	print('YES' if judge() else 'NO')


for _ in ' ' * int(input()):
	(n, k) = map(int, input().split())
	(*h,) = map(int, input().split())
	min_hs = [h[0]] * n
	max_hs = [h[0]] * n
	for i in range(1, n):
		min_touch = min_hs[i - 1] - k + 1
		max_touch = max_hs[i - 1] + k - 1
		min_ground = h[i]
		max_ground = h[i] + k - 1 if i != n - 1 else h[i]
		min_pos = max(min_touch, min_ground)
		max_pos = min(max_touch, max_ground)
		if min_pos > max_pos:
			print('NO')
			break
		min_hs[i] = min_pos
		max_hs[i] = max_pos
	else:
		print('YES')


case = int(input())
for c in range(case):
	(n, k) = map(int, input().split())
	myList = list(map(int, input().split()))
	mini = myList[0]
	maxi = myList[0]
	ok = True
	for ind1 in range(1, len(myList)):
		mini = max(myList[ind1], mini - (k - 1))
		maxi = min(myList[ind1] + k - 1, maxi + k - 1)
		if myList[ind1] > maxi or myList[ind1] + k - 1 < mini:
			ok = False
			break
	if myList[len(myList) - 1] < mini or myList[len(myList) - 1] > maxi:
		ok = False
	if ok:
		print('YES')
	else:
		print('NO')


def solve():
	[n, k] = map(int, input().split(' '))
	h = list(map(int, input().split(' ')))
	assert len(h) == n
	assert n >= 2
	lo = h[0] + 1
	hi = lo

	def bnd(x, xmin, xmax):
		return min(xmax, max(xmin, x))
	for i in range(1, n):
		new_lo = lo - (k - 1)
		new_hi = hi + (k - 1)
		if new_hi < h[i] + 1 or new_lo > h[i] + k:
			print('NO')
			return
		lo = bnd(new_lo, h[i] + 1, h[i] + k)
		hi = bnd(new_hi, h[i] + 1, h[i] + k)
		if lo > hi:
			print('NO')
			return
	print('YES' if lo <= h[n - 1] + 1 and h[n - 1] + 1 <= hi else 'NO')

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


t = int(input())
for testCaseCounter in range(t):
	splitted = [int(amit) for amit in input().split(' ')]
	n = splitted[0]
	k = splitted[1]
	arr = [int(amit) for amit in input().split(' ')]
	lowestStartingPoint = arr[0]
	highestStartingPoint = arr[0]
	valid = True
	for i in range(1, n):
		lowestStartingPoint = max(arr[i], lowestStartingPoint - (k - 1))
		highestStartingPoint = min(arr[i] + (k - 1), highestStartingPoint + (k - 1))
		if lowestStartingPoint > highestStartingPoint:
			valid = False
			break
	if valid and lowestStartingPoint <= arr[n - 1] <= highestStartingPoint:
		print('YES')
	else:
		print('NO')


from sys import *
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ini = [0 + l[0], k + l[0]]
	ans = 'YES'
	for i in range(1, n):
		pMin = ini[0] + 1 - k
		pMax = ini[1] - 1 + k
		if i < n - 1 and pMin - (k - 1) <= l[i] < ini[1]:
			ini = [max(pMin, l[i]), min(pMax, l[i] + k + k - 1)]
		elif i == n - 1 and pMin <= l[i] < ini[1]:
			pass
		else:
			ans = 'NO'
			break
	print(ans)


innum = lambda : int(input())
inmul = lambda : map(int, input().split())
instr = lambda : str(input())
inarr = lambda : list(map(int, input().split()))

def solve():
	(n, k) = inmul()
	a = inarr()
	ma = a[0]
	mi = a[0]
	for i in range(1, n - 1):
		mi = max(mi - (k - 1), a[i])
		ma = min(ma + k - 1, a[i] + k - 1)
		if mi > ma:
			print('NO')
			return
	if a[-1] >= mi - k + 1 and a[-1] <= ma + k - 1:
		print('YES')
	else:
		print('NO')

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


def getints():
	return list(map(int, input().split()))

def solve():
	(n, k) = getints()
	k1 = k - 1
	(hi, *hlist) = getints()
	lo = hi
	for h in hlist[:-1]:
		(lo, hi) = (max(lo - k1, h), min(hi + k1, h + k1))
		if hi < lo:
			return 'NO'
	if lo - k1 <= hlist[-1] <= hi + k1:
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	print(solve())


t = int(input())
for _ in range(t):
	(n, k) = tuple(map(int, input().split()))
	h = list(map(int, input().split()))
	top = h[0]
	bottom = h[0]
	check = True
	for i in range(1, n):
		top = min(top + k - 1, h[i] + k - 1)
		bottom = max(h[i], bottom - k + 1)
		if bottom > top:
			check = False
			break
	if h[n - 1] < bottom or h[n - 1] > top:
		check = False
	if check:
		print('YES')
	else:
		print('NO')


def Fence(ground, k):
	max_fence_last = ground[0] + k
	min_fence_last = ground[0]
	for i in range(1, len(ground)):
		max_f = min(max_fence_last + k - 1, ground[i] + k + k - 1)
		min_f = max(min_fence_last - k + 1, ground[i])
		if max_f - min_f < k:
			return 'NO'
		max_fence_last = max_f
		min_fence_last = min_f
	if min_f != ground[i]:
		return 'NO'
	else:
		return 'YES'
for i in range(int(input())):
	k = int(input().split()[1])
	ground = list(map(int, input().split()))
	print(Fence(ground, k))


t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split(' ')))
	heights = list(map(int, input().split(' ')))
	current_floor_range = [heights[0], heights[0]]
	is_possible = True
	for j in range(1, n):
		current_floor_range = [max(current_floor_range[0] - k + 1, heights[j]), min(current_floor_range[1], heights[j]) + k - 1]
		if current_floor_range[0] > current_floor_range[1]:
			is_possible = False
			break
	print('YES' if is_possible and current_floor_range[0] <= heights[n - 1] <= current_floor_range[1] else 'NO')


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	h = list(map(int, input().split()))
	minL = h[0]
	maxL = h[0]
	done = True
	for i in range(1, n):
		minL = max(minL - k + 1, h[i])
		maxL = min(maxL + k - 1, h[i] + k - 1)
		if minL > maxL:
			done = False
			break
	if h[n - 1] > maxL or h[n - 1] < minL:
		done = False
	if done == True:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	d = [[-1, -1] for i in range(n)]
	d[0] = [h[0], h[0]]
	ans = 'YES'
	for i in range(1, len(h)):
		d[i] = [max(h[i], d[i - 1][0] - (k - 1)), min(h[i] + (k - 1), d[i - 1][1] + (k - 1))]
		if d[i][0] - h[i] > k - 1:
			ans = 'NO'
			break
		if d[i - 1][1] + k <= d[i][0]:
			ans = 'NO'
			break
	if d[-1][0] > h[-1]:
		ans = 'NO'
	print(ans)


import sys
input = sys.stdin.readline

def solution():
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	if n == 2:
		if abs(h[0] - h[-1]) >= k:
			print('NO')
			return
	sweep = []
	for i in range(1, n - 1):
		sweep.append((h[i], i))
	sweep.sort(reverse=True)
	H = [-1] * n
	H[0] = h[0]
	H[-1] = h[-1]
	for (h_i, i) in sweep:
		cur = h_i
		if H[i - 1] != -1:
			cur = max(cur, H[i - 1] + 1 - k)
		if H[i + 1] != -1:
			cur = max(cur, H[i + 1] + 1 - k)
		if cur - h_i >= k:
			print('NO')
			return
		H[i] = cur
	for i in range(n - 1):
		if abs(H[i] - H[i + 1]) >= k:
			print('NO')
			return
	print('YES')
T = int(input())
for _ in range(T):
	solution()


import os, sys
from io import BytesIO, IOBase

def solve(n, k, h):
	ls = [[-1, -1] for _ in range(n)]
	for i in h:
		ran = [-1, -1]
		ran1 = [-1, -1]
		if i[1] and ls[i[1] - 1] != [-1, -1]:
			xx = max(0, ls[i[1] - 1][0] + 1 - i[0] - k)
			if xx >= k:
				return 'NO'
			ran = [i[0] + xx, i[0] + xx + k]
		if i[1] != n - 1 and ls[i[1] + 1] != [-1, -1]:
			xx1 = max(0, ls[i[1] + 1][0] + 1 - i[0] - k)
			if xx1 >= k:
				return 'NO'
			ran1 = [i[0] + xx1, i[0] + xx1 + k]
		ran = max([ran, ran1], key=lambda xxx: xxx[0])
		if not i[1] or i[1] == n - 1:
			if ran[0] != i[0] and ran[0] != -1:
				return 'NO'
		if ran == [-1, -1]:
			ls[i[1]] = [i[0], i[0] + k]
		else:
			ls[i[1]] = ran
	return 'YES'

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		h = list(map(lambda x: [int(x), 0], input().split()))
		for i in range(n):
			h[i][1] = i
		h.sort(key=lambda x: x[0], reverse=1)
		print(solve(n, k, h))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	hi = list(map(int, input().split()))
	minh = hi[0] - k + 1
	maxh = hi[0] + k - 1
	ans = 1
	for i in range(1, n - 1):
		curminh = hi[i]
		curmaxh = hi[i] + k - 1
		minh = max(curminh, minh)
		maxh = min(curmaxh, maxh)
		if minh > maxh:
			ans = 0
			break
		minh = minh - k + 1
		maxh = maxh + k - 1
	curminh = hi[-1]
	curmaxh = hi[-1]
	minh = max(curminh, minh)
	maxh = min(curmaxh, maxh)
	if minh > maxh:
		ans = 0
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	minh = [h[0] + k] + [0 for i in range(n - 1)]
	maxh = [h[0] + k] + [0 for i in range(n - 1)]
	flag = True
	for i in range(1, n - 1):
		if h[i] >= maxh[i - 1] or h[i] + 2 * k - 1 <= minh[i - 1] - k:
			flag = False
			break
		maxh[i] = min(maxh[i - 1] + k - 1, h[i] + 2 * k - 1)
		minh[i] = max(minh[i - 1] - k + 1, h[i] + k)
	if h[n - 1] + k > maxh[n - 2] + k - 1 or h[n - 1] + k < minh[n - 2] - k + 1:
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	h = list(map(int, input().split()))
	a = [0 for i in range(n)]
	poss = True
	for i in range(1, n - 1):
		lb = h[i - 1] + a[i - 1] - h[i] - k + 1
		ub = h[i - 1] + a[i - 1] - h[i] + k - 1
		if ub < 0 or lb >= k:
			poss = False
			break
		elif h[i + 1] > h[i]:
			a[i] = min(ub, k - 1)
		else:
			a[i] = max(lb, 0)
	if poss == True:
		lb = h[n - 2] + a[n - 2] - h[n - 1] - k + 1
		ub = h[n - 2] + a[n - 2] - h[n - 1] + k - 1
		if lb > 0 or ub < 0:
			poss = False
	if poss == True:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	h = [int(x) for x in input().split()]
	ans = 'YES'
	min_1 = h[0] - (k - 1)
	max_1 = h[0] + (k - 1)
	for i in range(1, n):
		min_2 = h[i]
		if i == n - 1:
			max_2 = min_2
		else:
			max_2 = h[i] + (k - 1)
		if max_1 < min_2 or min_1 > max_2:
			ans = 'NO'
			break
		min_1 = max(min_1, min_2) - (k - 1)
		max_1 = min(max_1, max_2) + (k - 1)
	print(ans)


import sys
input = sys.stdin.readline

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		h = list(map(int, input().split()))
		currmax = h[0] + k
		f = 0
		for i in range(1, n - 1):
			if h[i] >= currmax:
				f = 1
			elif h[i] >= h[i - 1]:
				if h[i + 1] >= h[i]:
					currmax = h[i] + min(k - 1, currmax - h[i] - 1) + k
				else:
					currmax = h[i] + k
			elif h[i] + k + k - 1 <= currmax - k:
				f = 1
			elif h[i + 1] >= h[i]:
				currmax = h[i] + k + k - 1
			else:
				now = h[i] + k
				if now <= currmax - k:
					now += currmax - k - now + 1
				currmax = now
		if h[n - 1] >= currmax:
			f = 1
		elif h[n - 1] + k <= currmax - k:
			f = 1
		if f:
			print('NO')
		else:
			print('YES')
	return
main()


def cmp(a, h):
	return [max(a[0], h[0]), min(a[1], h[1])]
t = input()
for _ in range(int(t)):
	sign = 0
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	height = input().split(' ')
	height = [int(he) for he in height]
	now = [height[0], height[0]]
	for i in range(1, n):
		tem = cmp([height[i], height[i] + k - 1], [now[0] - k + 1, now[1] + k - 1]) if i != n - 1 else cmp([height[i], height[i]], [now[0] - k + 1, now[1] + k - 1])
		if tem[1] < tem[0]:
			sign = 1
			print('NO')
			break
		else:
			now = tem
	if sign == 0:
		print('YES')


from sys import stdin, exit
from bisect import bisect_left as bl, bisect_right as br
input = lambda : stdin.readline()[:-1]
intput = lambda : int(input())
sinput = lambda : input().split()
intsput = lambda : map(int, sinput())

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
t = intput()
for _ in range(t):
	(n, k) = intsput()
	heights = list(intsput())
	upper = heights[0]
	lower = heights[0]
	fail = False
	for i in range(1, n):
		upper = upper + k - 1
		lower = lower - k + 1
		l_upper = heights[i] + k - 1
		l_lower = heights[i]
		if upper < l_lower or l_upper < lower:
			fail = True
			break
		else:
			upper = min(upper, l_upper)
			lower = max(lower, l_lower)
	if lower <= heights[-1] <= upper:
		pass
	else:
		fail = True
	if fail:
		print('NO')
	else:
		print('YES')


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return list(map(int, sys.stdin.readline().strip().split()))[0]

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
N = 0
a = []

def solve():
	global N
	(N, k) = get_ints()
	a = get_list()
	mx = a[0]
	mn = a[0]
	possible = True
	for i in a[1:]:
		mn = max(mn - (k - 1), i)
		mx = min(mx + (k - 1), i + (k - 1))
		if mx < mn:
			possible = False
			break
	if a[-1:][0] not in range(mn, mx + 1):
		possible = False
	print('YES' if possible else 'NO')
test_cases = get_int()
for _ in range(test_cases):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [*map(int, input().split())]
	b = [(a[0], a[0])]
	f = 0
	for i in range(1, n):
		x = max(b[i - 1][0] - (k - 1), a[i])
		y = min(b[i - 1][1] + (k - 1), a[i] + (k - 1))
		b.append((x, y))
		if x > y:
			f = 1
			break
	if a[n - 1] not in range(x, y + 1):
		f = 1
	if f:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	H = [int(h) for h in input().split()]
	(a, b) = (H[0], H[0] + k)
	ans = 'YES'
	for h in H[1:-1]:
		(x, y) = (h, h + 2 * k - 1)
		a = max(x, a - k + 1)
		b = min(y, b + k - 1)
		if b - a < k:
			ans = 'NO'
	if H[-1] >= b or H[-1] + k <= a:
		ans = 'NO'
	print(ans)


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]

def solve(N, K, H):
	dp = [[0, 0] for _ in range(N)]
	dp[0] = [H[0], H[0]]
	for i in range(1, N):
		a = max(dp[i - 1][0] - K + 1, H[i])
		b = min(dp[i - 1][1] + K - 1, H[i] + K - 1)
		if a > b:
			return False
		dp[i] = [a, b]
	return dp[N - 1][0] == H[N - 1]

def main():
	N0 = int(input())
	for _ in range(N0):
		(N, K) = map(int, input().split())
		H = list(map(int, input().split()))
		if solve(N, K, H):
			print('YES')
		else:
			print('NO')
main()


def readInt():
	return int(input())

def readLine():
	return [int(s) for s in input().split(' ')]

def readString():
	return input()

def ask(arr, k):
	pLow = arr[0]
	pHigh = arr[0]
	for i in range(len(arr)):
		t = arr[i]
		pLow = pLow - (k - 1)
		pHigh = pHigh + (k - 1)
		if i == len(arr) - 1 or i == 0:
			allowLow = t
			allowHigh = t
		else:
			allowLow = t
			allowHigh = t + k - 1
		if allowLow > pHigh or pLow > allowHigh:
			return False
		pLow = max(allowLow, pLow)
		pHigh = min(allowHigh, pHigh)
	return True
t = readInt()
for _ in range(t):
	(n, k) = readLine()
	arrs = readLine()
	result = ask(arrs, k)
	if result:
		print('YES')
	else:
		print('NO')


import sys

def input():
	return sys.stdin.readline().strip()

def solve():
	for t in range(int(input())):
		(n, k) = map(int, input().split())
		k -= 1
		ii = iter(map(int, input().split()))
		m = next(ii)
		M = m
		bad = False
		for h in ii:
			m = max(m - k, h)
			M = min(M + k, h + k)
			if m > M:
				bad = True
				break
		if not bad and m <= h and (M >= h):
			print('YES')
		else:
			print('NO')
solve()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	h = list(map(int, input().split()))
	min1 = h[0]
	max1 = h[0] + k
	yes = 0
	for i in range(1, n - 1):
		if h[i] + 2 * k - 1 <= min1 or h[i] >= max1:
			yes = 1
			break
		else:
			if h[i] >= min1:
				min1 = h[i]
			else:
				min1 = max(min1 - k + 1, h[i])
			if h[i] + k * 2 - 1 <= max1:
				max1 = h[i] + k * 2 - 1
			else:
				max1 = min(max1 + k - 1, h[i] + k * 2 - 1)
	if min1 >= k + h[-1] or max1 <= h[-1] or yes == 1:
		print('NO')
	else:
		print('YES')


class minmax:

	def __init__(self, min_, max_):
		self.min_ = min_
		self.max_ = max_

def lop():
	(n, k) = map(int, input().split())
	h = input().split()
	this_range = minmax(0, 0)
	prev_range = minmax(0, 0)
	for i in range(n):
		if i == 0 or i == n - 1:
			this_range = minmax(int(h[i]) + k, int(h[i]) + k)
		else:
			this_range = minmax(max(prev_range.min_ - k + 1, int(h[i]) + k), min(prev_range.max_ + k - 1, int(h[i]) + 2 * k - 1))
		if this_range.min_ > this_range.max_:
			return 'NO'
		if i == n - 1:
			u = this_range.min_
			if u < prev_range.min_ - k + 1 or u > prev_range.max_ + k - 1:
				return 'NO'
		prev_range = this_range
	return 'YES'
t = int(input())
out = []
for p in range(t):
	out.append(lop())
for p in out:
	print(p)


import math
t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	max_height = list1[0] + k
	min_height = list1[0] + k
	f = 0
	for i in range(1, n - 1):
		if list1[i] >= max_height or list1[i] + k + k - 1 <= min_height - k:
			f = 1
			break
		max_height = min(list1[i] + k - 1, max_height - 1) + k
		min_height = max(list1[i], min_height - 2 * k + 1) + k
	if f == 0:
		if not (min_height - k < list1[-1] + k and list1[-1] < max_height):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	start = [max(a[0] - k + 1, 0), a[0] + k - 1]
	ok = True
	for i in range(1, n):
		if not ok:
			break
		if i != n - 1:
			p1 = a[i] + k - 1
			p2 = a[i]
			if start[0] <= p2 <= start[1] or start[0] <= p1 <= start[1]:
				l = [max(p2, start[0]), min(p1, start[1])]
				start = [max(l[0] - k + 1, 0), l[1] + k - 1]
			else:
				ok = False
		else:
			p1 = a[i]
			p2 = a[i]
			if start[0] <= p2 <= start[1] or start[0] <= p1 <= start[1]:
				l = [max(p2, start[0]), min(p1, start[1])]
				start = [max(l[0] - k + 1, 0), l[1] + k - 1]
			else:
				ok = False
	if ok:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ma = a[0]
	mi = a[0]
	f = True
	for i in range(1, n):
		if a[i] > a[i - 1]:
			if not k - 1 >= abs(ma - a[i]):
				f = False
		elif not 2 * (k - 1) >= abs(mi - a[i]):
			f = False
		ma = min(a[i] + k - 1, ma + k - 1)
		mi = max(a[i], mi - k + 1)
	if f and mi == a[n - 1]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	m = 0
	str = input()
	(_, k) = [int(item) for item in str.split(' ')]
	str = input()
	ground = [int(item) for item in str.split(' ')]
	(_min, _max) = (ground[0], ground[0])
	for i in range(1, len(ground)):
		_min -= k - 1
		_max += k - 1
		if _min < ground[i]:
			_min = ground[i]
		if _max > ground[i] + k - 1:
			_max = ground[i] + k - 1
		if _min > _max:
			print('NO')
			m = 1
			break
	if m == 0:
		if _min == ground[-1]:
			print('YES')
		else:
			print('NO')


import copy
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def exgcd(a, b):
	if not b:
		return (1, 0)
	(y, x) = exgcd(b, a % b)
	y -= a // b * x
	return (x, y)

def getinv(a, m):
	(x, y) = exgcd(a, m)
	return --1 if x == 1 else x % m

def comb(n, b):
	res = 1
	b = min(b, n - b)
	for i in range(b):
		res = res * (n - i) * getinv(i + 1, mo) % mo
	return res % mo
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	li = [int(i) for i in input().split()]
	cur = li[0]
	ans = True
	upp = cur
	low = cur
	for (p, i) in enumerate(li[1:]):
		if i > upp and i - upp < k or (i < low and low - i < k + k - 1) or low <= i <= upp:
			upp = min(i + (k - 1), upp + (k - 1))
			low = max(i, low - (k - 1))
		else:
			ans = False
			break
	li.reverse()
	cur = li[0]
	upp = cur
	low = cur
	for (p, i) in enumerate(li[1:]):
		if i > upp and i - upp < k or (i < low and low - i < k + k - 1) or low <= i <= upp:
			upp = min(i + (k - 1), upp + (k - 1))
			low = max(i, low - (k - 1))
		else:
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')


cases = int(input())
ans_list = []
for c in range(cases):
	(n, k) = list(map(int, input().split(' ')))
	heights = list(map(int, input().split(' ')))
	max_top = heights[0] + k
	min_top = heights[0] + k
	ans = 'YES'
	for i in range(1, n - 1):
		if heights[i] >= max_top or heights[i] + k + k - 1 <= min_top - k:
			ans = 'NO'
			break
		max_top = min(heights[i] + k - 1, max_top - 1) + k
		min_top = max(heights[i], min_top - 2 * k + 1) + k
	if ans == 'YES':
		if not (min_top - k < heights[-1] + k and heights[-1] < max_top):
			ans = 'NO'
	ans_list.append(ans)
print('\n'.join(ans_list))


import sys
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
for _ in range(ii1()):
	(n, k) = iia()
	(l, r) = (0, 0)
	arr = iia()
	ans = 'YES'
	for i in range(n):
		h = arr[i]
		if i == 0:
			l = r = h
		else:
			l = max(l - k + 1, h)
			r = min(r + k - 1, h + k - 1)
		if l > r:
			ans = 'NO'
		if i == n - 1 and l != h:
			ans = 'NO'
	print(ans)


def main():
	from sys import stdin
	input = stdin.buffer.readline
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		(*h,) = map(int, input().split())
		mn = [0] * n
		mx = [0] * n
		mn[0] = mx[0] = h[0]
		for i in range(1, n):
			mn[i] = max(h[i], mn[i - 1] - k + 1)
			mx[i] = min(h[i], mx[i - 1]) + k - 1
			if mn[i] > mx[i]:
				print('NO')
				break
		else:
			if mn[n - 1] <= h[n - 1] <= mx[n - 1]:
				print('YES')
			else:
				print('NO')
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	mn = arr[0]
	mx = arr[0]
	flage = True
	for i in range(1, n):
		mn = max(arr[i], mn - k + 1)
		mx = min(arr[i] + k - 1, mx + k - 1)
		if mn > mx:
			flage = False
	if mn > arr[n - 1] or mx < arr[n - 1]:
		flage = False
	if flage:
		print('YES')
	else:
		print('NO')


def fence():
	(n, k) = map(int, input().split())
	h = list(map(int, input().split()))
	low = h[0]
	high = h[0]
	for (a, b) in enumerate(h):
		low = max(low, b)
		high = min(high, b + k - 1 if a > 0 and a < n - 1 else b)
		if low > high:
			return False
		low -= k - 1
		high += k - 1
	return True
tests = int(input())
for t in range(tests):
	print('YES' if fence() else 'NO')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	x = a[0]
	for j in range(1, n):
		if a[j] <= a[j - 1]:
			x = max(a[j], x - k + 1)
		if a[j] > a[j - 1]:
			x = a[j]
		if x - a[j] >= k:
			c = c + 1
			break
	if x != a[n - 1]:
		c = c + 1
	x = a[n - 1]
	for j in range(n - 2, -1, -1):
		if a[j] <= a[j + 1]:
			x = max(a[j], x - k + 1)
		if a[j] > a[j + 1]:
			x = a[j]
		if x - a[j] >= k:
			c = c + 1
			break
	if x != a[0]:
		c = c + 1
	if c > 0:
		print('NO')
	else:
		print('YES')


from sys import stdin
t = int(stdin.readline())

def run():
	L = [int(x) for x in stdin.readline().split(' ')]
	(n, k) = (L[0], L[1])
	A = [int(x) for x in stdin.readline().split(' ')]
	lo = A[0]
	hi = A[0]
	for i in range(1, n):
		lo = max(lo - (k - 1), A[i])
		hi = min(A[i] + (k - 1), hi + (k - 1))
		if lo > hi:
			print('NO')
			return
	if lo <= A[-1] <= hi:
		print('YES')
	else:
		print('NO')
for _ in range(t):
	run()


for y in range(int(input())):
	(n, m) = map(int, input().split())
	lst = list(map(int, input().split()))
	flag = 0
	if n == 1:
		print('YES')
		continue
	minstart = maxstart = 0
	for i in range(n):
		if i == 0:
			minstart = lst[0]
			maxstart = lst[0]
			minend = maxend = lst[0] + m - 1
		else:
			minstart = minstart - (m - 1)
			maxstart = maxstart + (m - 1)
			if lst[i] < minstart - (m - 1) or lst[i] > maxstart:
				flag = 1
				break
			minstart = max(lst[i], minstart)
			maxstart = min(lst[i] + (m - 1), maxstart)
		if i == n - 1:
			if lst[i] < minstart or lst[i] > maxstart:
				flag = 1
				break
	if flag == 0:
		print('YES')
	else:
		print('NO')


def get_overlap(A, B):
	(p, q) = A
	(r, s) = B
	haha = [r - K + 1, s - 1]
	nxt_a = max(p, haha[0])
	nxt_b = min(q, haha[1])
	if nxt_b >= nxt_a:
		return [nxt_a, nxt_b]
	else:
		return False
for _ in range(int(input())):
	(N, K) = map(int, input().split())
	heights = list(map(int, input().split()))
	base_range = []
	base_range.append([heights[0], heights[0]])
	possible = True
	for i in range(1, N - 1):
		possible_base_range = [heights[i], heights[i] + K - 1]
		possible_last_range = [base_range[i - 1][0], base_range[i - 1][1] + K]
		nxt = get_overlap(possible_base_range, possible_last_range)
		if nxt == False:
			possible = False
			break
		else:
			base_range.append(nxt)
	if possible:
		possible_base_range = [heights[N - 1], heights[N - 1]]
		possible_last_range = [base_range[N - 2][0], base_range[N - 2][1] + K]
		nxt = get_overlap(possible_base_range, possible_last_range)
		if nxt == False:
			possible = False
	if possible:
		print('YES')
	else:
		print('NO')


def share(l1, u1, l2, u2):
	if l2 < u1 and l2 >= l1 or (u2 > l1 and u2 <= u1):
		return True
	return False
t = int(input())
for z in range(t):
	(n, k) = [int(i) for i in input().split()]
	h = [int(i) for i in input().split()]
	(u, l) = (h[0] + k, h[0])
	c = 0
	for i in range(1, n - 1):
		if share(l, u, h[i], h[i] + k) or share(l, u, h[i] + k - 1, h[i] + k + k - 1):
			lmin = max(h[i], l + 1 - k)
			umax = min(h[i] + k + k - 1, u - 1 + k)
			(u, l) = (umax, lmin)
		else:
			c = 1
	if c == 0 and share(l, u, h[n - 1], h[n - 1] + k) == False:
		c = 1
	if c == 0:
		print('YES')
	else:
		print('NO')


import sys
import io, os
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	H = list(map(int, input().split()))
	m = H[0]
	M = H[0]
	for i in range(1, n):
		m = max(m + 1 - k, H[i])
		M = min(H[i] + k - 1, M + k - 1)
		if M < m:
			print('NO')
			break
	else:
		if m != H[-1]:
			print('NO')
		else:
			print('YES')


from functools import cmp_to_key
from collections import deque, Counter
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def si():
	return str(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def lsi():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)
MOD = 10 ** 9 + 7
maxN = 5
FACT = [0] * maxN
INV_FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def inverseFactorials():
	n = len(INV_FACT)
	INV_FACT[n - 1] = inverse(FACT[n - 1])
	for i in range(n - 2, -1, -1):
		INV_FACT[i] = multiply(INV_FACT[i + 1], i + 1)

def coeffBinom(n, k):
	if n < k:
		return 0
	return multiply(FACT[n], multiply(INV_FACT[k], INV_FACT[n - k]))

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path

def interseca(l1, r1, l2, r2):
	if r1 < l2 or r2 < l1:
		return False
	return True
for test in range(ii()):
	[n, k] = li()
	h = li()
	cur = [h[0], h[0]]
	flag = True
	for i in range(1, n - 1):
		if h[i + 1] > h[i]:
			l = min(h[i] + k - 1, cur[1] + k - 1)
			if l < h[i] or l > h[i] + k - 1:
				flag = False
			flag = flag and interseca(l, l + k - 1, cur[0], cur[1] + k - 1)
			cur = [l, l]
		elif h[i + 1] < h[i]:
			l = max(h[i], cur[0] - k + 1)
			if l < h[i] or l > h[i] + k - 1:
				flag = False
			flag = flag and interseca(l, l + k - 1, cur[0], cur[1] + k - 1)
			cur = [l, l]
		elif h[i - 1] == h[i]:
			cur[0] = max(h[i], cur[0] - k + 1)
			cur[1] = min(h[i] + k - 1, cur[1] + k - 1)
		else:
			mi = max(cur[0] - k + 1, h[i])
			ma = min(h[i] + k - 1, cur[1] + k - 1)
			if mi > ma or interseca(mi, ma + k - 1, cur[0], cur[1] + k - 1) == False:
				flag = False
			cur = [mi, ma]
	if h[n - 1] < cur[0] - k + 1 or h[n - 1] > cur[1] + k - 1:
		flag = False
	if flag == False:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	t -= 1
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	v = [int(x) for x in input().split(' ')]
	mn = v[0]
	mx = v[0]
	ok = True
	for i in range(1, n):
		mn = max(v[i], mn - k + 1)
		mx = min(v[i] + k - 1, mx + k - 1)
		if mn > mx:
			ok = False
			break
	if mn > v[n - 1] or mx < v[n - 1]:
		ok = False
	if ok == True:
		print('YES')
	else:
		print('NO')


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
t = int(input())
for tt in range(t):
	(n, k) = nii()
	h = lnii()
	min_h = h[0]
	max_h = h[0] + k
	for i in range(1, n):
		if i < n - 1:
			if h[i] > max_h - 1:
				print('NO')
				break
			min_h = max(h[i], min_h - (k - 1))
			max_h = min(max_h + (k - 1), h[i] + k + (k - 1))
			if min_h + k > max_h:
				print('NO')
				break
		elif min_h >= h[i] + k or max_h <= h[i]:
			print('NO')
		else:
			print('YES')