runtime Error(NZEC) while running python code

test = int(input())
while test > 0:
x, y = [int(input()), int(input())]
array = []
for var in range(0, x):
array.append(float(input()))
i = 0
min_move = 0
m = 0
while (x - 1) > 0:
d = array[i + 1] - array[i]
q = (y - d) / 2
if y > d and m == 0:
if q > (array[0] - m):
if (array[0] - m) > min_move:
min_move = (array[0] - m)
array[0] = m
else:
if abs(q) > min_move:
min_move = abs(q)
array[0] -= q
d = (array[i + 1] - array[i])
if y > d:
if abs(y - d) > min_move:
min_move = abs(y - d)
array[i + 1] = array[i + 1] + (y - d)
m = array[i + 1]
i += 1
x -= 1
print(min_move)
test -= 1