Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.

The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has $n$ hotels, where the $i$-th hotel is located in the city with coordinate $x_i$. Sonya is a smart girl, so she does not open two or more hotels in the same city.

Sonya understands that her business needs to be expanded by opening new hotels, so she decides to build one more. She wants to make the minimum distance from this hotel to all others to be equal to $d$. The girl understands that there are many possible locations to construct such a hotel. Thus she wants to know the number of possible coordinates of the cities where she can build a new hotel. 

Because Sonya is lounging in a jacuzzi in one of her hotels, she is asking you to find the number of cities where she can build a new hotel so that the minimum distance from the original $n$ hotels to the new one is equal to $d$.


-----Input-----

The first line contains two integers $n$ and $d$ ($1\leq n\leq 100$, $1\leq d\leq 10^9$) — the number of Sonya's hotels and the needed minimum distance from a new hotel to all others.

The second line contains $n$ different integers in strictly increasing order $x_1, x_2, \ldots, x_n$ ($-10^9\leq x_i\leq 10^9$) — coordinates of Sonya's hotels.


-----Output-----

Print the number of cities where Sonya can build a new hotel so that the minimum distance from this hotel to all others is equal to $d$.


-----Examples-----
Input
4 3
-3 2 9 16

Output
6

Input
5 2
4 8 11 18 19

Output
5



-----Note-----

In the first example, there are $6$ possible cities where Sonya can build a hotel. These cities have coordinates $-6$, $5$, $6$, $12$, $13$, and $19$.

In the second example, there are $5$ possible cities where Sonya can build a hotel. These cities have coordinates $2$, $6$, $13$, $16$, and $21$.

Difficulty: EASY
Tags: Implementation
Expected Time Complexity: O(N)

Starter code:

Solutions:
l1 = [int(x) for x in input().split()]
(n, d) = (l1[0], l1[1])
l2 = [int(x) for x in input().split()]
l2.sort()
l3 = [l2[0] - d, l2[-1] + d]
if len(l2) == 1:
	print(2)
else:
	if abs(l2[1] - (l2[0] + d)) >= d:
		l3.append(l2[0] + d)
	if abs(l2[-2] - (l2[-1] - d)) >= d:
		l3.append(l2[-1] - d)
	for y in range(1, len(l2) - 1):
		x = l2[y]
		if abs(l2[y + 1] - (l2[y] + d)) >= d:
			l3.append(x + d)
		if abs(l2[y - 1] - (l2[y] - d)) >= d:
			l3.append(x - d)
	print(len(set(l3)))


(n, d) = map(int, input().split())
li = list(map(int, input().split()))
ans = 2
length = len(li)
for i in range(0, length - 1):
	dif = li[i + 1] - li[i]
	if dif == 2 * d:
		ans += 1
	elif dif > 2 * d:
		ans += 2
print(ans)


(n, d) = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 2
i = 0
while i < n - 1:
	if a[i + 1] - d > a[i] + d:
		ans += 2
	if a[i + 1] - d == a[i] + d:
		ans += 1
	i += 1
print(ans)


(n, d) = input().split()
(n, d) = (int(n), int(d))
arr = input().split()
for i in range(len(arr)):
	arr[i] = int(arr[i])
count = 0
points = []
if len(arr) >= 1:
	count = count + 2
for i in range(1, len(arr)):
	if arr[i] - arr[i - 1] > d * 2:
		count = count + 2
	if arr[i] - arr[i - 1] == d * 2:
		count = count + 1
print(count)


(n, d) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ans = 2
for i in range(n - 1):
	if a[i + 1] - a[i] > 2 * d:
		ans += 2
	if a[i + 1] - a[i] == 2 * d:
		ans += 1
print(ans)


(n, d) = list(map(int, input().strip().split()))
l = list(map(int, input().strip().split()))
t = []
if n == 1:
	print('2')
else:
	for i in range(len(l)):
		if i == 0:
			t += [l[0] - d]
			s = l[0] + d
			if l[i + 1] - s >= d:
				t += [s]
		elif i == n - 1:
			t += [l[i] + d]
			s = l[i] - d
			if s - l[i - 1] >= d:
				t += [s]
		else:
			s = l[i] - d
			if s - l[i - 1] >= d:
				t += [s]
			s = l[i] + d
			if l[i + 1] - s >= d:
				t += [s]
	print(len(set(t)))


(n, d) = map(int, input().split())
x = list(sorted(map(int, input().split())))
positions = set()
for i in range(len(x)):
	if i == 0 or x[i] - d >= x[i - 1] + d:
		positions.add(x[i] - d)
	if i == n - 1 or x[i] + d <= x[i + 1] - d:
		positions.add(x[i] + d)
print(len(positions))


(n, d) = input().split(' ')
n = int(n)
d = int(d)
x = input().split(' ')
for i in range(n):
	x[i] = int(x[i])
counter = 2
for i in range(n - 1):
	start = x[i]
	end = x[i + 1]
	if end - start < 2 * d:
		counter += 0
	elif end - start == 2 * d:
		counter += 1
	else:
		counter += 2
print(counter)


from math import *
import sys
input = sys.stdin.readline

def main():
	(n, d) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	a = [-100000000000] + a + [100000000000]
	if n == 1:
		print(2)
		return
	cnt = 0
	for i in range(1, len(a) - 1):
		if a[i + 1] - a[i] == 2 * d:
			cnt += 1
		elif a[i + 1] - a[i] > 2 * d:
			cnt += 1
		if a[i] - a[i - 1] == 2 * d:
			continue
		elif a[i] - a[i - 1] > 2 * d:
			cnt += 1
	print(cnt)
main()


(n, d) = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
sorted(a)
x = 0
for i in range(1, n):
	if a[i] - a[i - 1] > 2 * d:
		x += 2
	elif a[i] - a[i - 1] == 2 * d:
		x += 1
x += 2
print(x)


read = lambda : map(int, input().split())
(n, d) = read()
a = [*read()]
print(2 + sum(((y - x >= 2 * d) + (y - x > 2 * d) for (x, y) in zip(a, a[1:]))))


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = 2
for i in range(n - 1):
	if l[i + 1] - l[i] > 2 * m:
		ans += 2
	elif l[i + 1] - l[i] == 2 * m:
		ans += 1
print(ans)


import math as ma
from sys import exit
from decimal import Decimal as dec

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

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

def nu():
	return int(input())
(n, d) = num()
a = li()
count = 2
for i in range(len(a) - 1):
	if a[i + 1] - a[i] >= 2 * d:
		if a[i + 1] - a[i] == 2 * d:
			count += 1
		else:
			count += 2
print(count)


(n, d) = input().split()
(n, d) = (int(n), int(d))
li1 = list(map(int, input().split()))
pagol = len(li1)
coun = 2
for i in range(pagol - 1):
	aa = abs(li1[i] - li1[i + 1]) - 1 - (d - 1) * 2
	if aa > 0 and aa < 2:
		coun += 1
	elif aa > 0 and aa >= 2:
		coun += 2
print(coun)


(n, min_distance) = [int(x) for x in input().split()]
hotels = [int(x) for x in input().split()]
spots = 2
for i in range(n - 1):
	distance = abs(hotels[i] - hotels[i + 1])
	if distance > 2 * min_distance:
		spots += 2
	elif distance == 2 * min_distance:
		spots += 1
print(spots)


(n, d) = (int(x) for x in input().split())
x = [int(x) for x in input().split()]
ans = 2
count = 0
if n > 1:
	if x[0] + d < x[1] - d:
		ans += 1
	if x[n - 1] - d > x[n - 2] + d:
		ans += 1
	if x[n - 1] - d == x[n - 2] + d:
		ans += 1
		count += 1
	if x[0] + d == x[1] - d:
		ans += 1
		count += 1
for i in range(1, n - 1):
	if x[i] - d > x[i - 1] + d:
		ans += 1
	if x[i] + d < x[i + 1] - d:
		ans += 1
	if x[i] - d == x[i - 1] + d:
		ans += 1
		count += 1
	if x[i] + d == x[i + 1] - d:
		ans += 1
		count += 1
print(ans - count // 2)


(n, d) = map(int, input().split())
city = list(map(int, input().split()))
city.sort()
count = 2
for i in range(n - 1):
	if city[i + 1] - city[i] > 2 * d:
		count += 2
	elif city[i + 1] - city[i] == 2 * d:
		count += 1
print(count)


def near(w, x):
	t = x[0]
	for i in range(len(x)):
		if abs(w - x[i]) < abs(w - t):
			t = x[i]
	return t

def find(w, x):
	if w < x[0]:
		return 0
	n = len(x) - 1
	if w > x[n]:
		return n
	for i in range(len(x)):
		if x[i] <= w < x[i + 1]:
			return i + 1
st = input()
n = int(st.split()[0])
d = int(st.split()[1])
st = input()
s = 2
x = []
for i in range(n):
	x.append(int(st.split()[i]))
k = x[0] + d
for i in range(len(x) - 1):
	if x[i + 1] - x[i] > 2 * d:
		s += 2
	if x[i + 1] - x[i] == 2 * d:
		s += 1
print(s)


(n, d) = input().split()
n = int(n)
d = int(d)
a = list(map(int, input().split()))
b = []
b.append(a[0] - d)
for i in range(len(a)):
	if i != 0:
		if a[i] - 2 * d >= a[i - 1]:
			b.append(a[i] - d)
	if i != len(a) - 1:
		if a[i] + 2 * d <= a[i + 1]:
			b.append(a[i] + d)
b.append(a[len(a) - 1] + d)
ans = 1
for i in range(1, len(b)):
	if b[i] != b[i - 1]:
		ans += 1
print(ans)


(n, d) = list(map(int, input().split()))
data = list(map(int, input().split()))
ans = 1
for i in range(n):
	if i == 0:
		ans += 1
		continue
	if data[i] - data[i - 1] >= 2 * d:
		if data[i] - data[i - 1] != 2 * d:
			ans += 2
		else:
			ans += 1
print(ans)


(n, d) = map(int, input().split())
m = list(map(int, input().split()))
q = 2 * n
for i in range(n - 1):
	if not m[i + 1] - m[i] > 2 * d:
		q -= 2
		if m[i + 1] - m[i] == 2 * d:
			q += 1
print(q)


(N, d) = map(int, input().split())
X = list(map(int, input().split()))
Z = set(X)
Y = set()
if N >= 2:
	Y.add(X[0] - d)
	if not X[0] + d in Z and X[1] - X[0] >= 2 * d:
		Y.add(X[0] + d)
	for i in range(1, N - 1):
		if not X[i] - d in Z and X[i] - X[i - 1] >= 2 * d:
			Y.add(X[i] - d)
		if not X[i] + d in Z and X[i + 1] - X[i] >= 2 * d:
			Y.add(X[i] + d)
	if not X[N - 1] - d in Z and X[N - 1] - X[N - 2] >= 2 * d:
		Y.add(X[N - 1] - d)
	Y.add(X[N - 1] + d)
else:
	Y.add(X[0] - d)
	Y.add(X[0] + d)
print(len(Y))


(a, b) = map(int, input().split())
c = [int(c) for c in input().split()]
d = 0
for i in range(a - 1):
	if abs(c[i] - c[i + 1]) < 2 * b:
		d += 0
	elif abs(c[i] - c[i + 1]) == 2 * b:
		d += 1
	else:
		d += 2
d += 2
print(d)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
b = set(map(d.__rsub__, a))
b.update(map(d.__add__, a))
c = set(filter(lambda x: min(map(lambda y: abs(x - y), a)) == d, b))
print(len(c))


(n, m) = input().strip().split(' ')
(n, m) = (int(n), int(m))
temp = []
arr = list(map(int, input().strip().split(' ')))
for i in arr:
	temp.append(i - m)
	temp.append(i + m)
temp = list(set(temp))
ans = []
d = m
for i in temp:
	flag = 1
	for j in arr:
		if abs(i - j) < d:
			flag = 0
	if flag:
		ans.append(i)
print(len(ans))


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
s = set()

def check(x):
	global d
	mind = 10000000000
	for i in a:
		mind = min(mind, abs(i - x))
	return mind == d
for i in a:
	if check(i - d):
		s.add(i - d)
	if check(i + d):
		s.add(i + d)
print(len(s))


(n, d) = map(int, input().split())
u = list(map(int, input().split()))
ans = 2
d *= 2
for i in range(1, n):
	if u[i] - u[i - 1] == d:
		ans += 1
	elif u[i] - u[i - 1] > d:
		ans += 2
print(ans)


(n, d) = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
s = 0
for i in range(n - 1):
	if L[i + 1] - L[i] == 2 * d:
		s += 1
	elif L[i + 1] - L[i] > 2 * d:
		s += 2
s += 2
print(s)


(n, b) = map(int, input().split())
l = list(map(int, input().split()))
s = 2
for x in range(n - 1):
	d = l[x + 1] - l[x]
	if d == 2 * b:
		s += 1
	elif d > 2 * b:
		s += 2
print(s)


def ii():
	return int(input())

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

def li():
	return list(mi())
(n, d) = mi()
a = li()
a.sort()
ans = set()
for i in range(n):
	x = a[i] - d
	y = a[i] + d
	if i == 0 or a[i - 1] <= x - d:
		ans.add(x)
	if i == n - 1 or y + d <= a[i + 1]:
		ans.add(y)
print(len(ans))


line = input().split()
n = int(line[0])
d = int(line[1])
x = [int(xi) for xi in input().split()]
res = 2
for i in range(0, n - 1):
	if x[i + 1] - x[i] == 2 * d:
		res += 1
	elif x[i + 1] - x[i] > 2 * d:
		res += 2
print(res)


a = input().split()
n = int(a[0])
d = int(a[1])
b = input().split()
count = 2
for i in range(n - 1):
	if int(b[i]) + d <= int(b[i + 1]) - d:
		count += 1
		if int(b[i + 1]) - d > int(b[i]) + d:
			count += 1
print(count)


(a, b) = map(int, input().split())
List = list(map(int, input().split()))
count = 0
for i in range(a - 1):
	x = abs(List[i + 1] - (List[i] + b))
	if x == b:
		count = count + 1
	elif x > b:
		count = count + 2
print(count + 2)


(n, d) = map(int, input().split())
hotels = list(map(int, input().split()))
count = 2
for i in range(n - 1):
	dis = hotels[i + 1] - hotels[i]
	if dis > d * 2:
		count += 2
	elif dis == d * 2:
		count += 1
print(count)


(n, d) = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
r = 0
for i in range(0, n - 1):
	dif = x[i + 1] - x[i]
	if dif == 2 * d:
		r += 1
	elif dif > 2 * d:
		r += 2
print(r + 2)


(x, y) = map(int, input().split())
a = list(map(int, input().split()))
n = [0 if i < 1 else 1 if i == 1 else 2 for i in [a[i + 1] - a[i] - 2 * y + 1 for i in range(x - 1)]]
print(sum(n) + 2)


(n, d) = map(int, input().split())
X = list(map(int, input().split()))
print(2 + sum((0 if x2 - x1 < 2 * d else 2 if x2 - x1 > 2 * d else 1 for (x1, x2) in zip(X, X[1:]))))


(n, d) = map(int, input().split())
s = list(map(int, input().split()))
ans = 2
for i in range(n - 1):
	x = s[i] + d
	y = s[i + 1] - d
	if abs(x - s[i + 1]) >= d:
		ans += 1
	if abs(y - s[i]) >= d and x != y:
		ans += 1
print(ans)


(c_count, dest) = input().split(' ')
coord = list(input().split(' '))
res = 0
x_vst = 0
for i in range(int(c_count)):
	if i == 0:
		x_vst = int(coord[i]) - int(dest)
		res += 1
	if i != 0 and int(coord[i]) - 2 * int(dest) > int(coord[i - 1]):
		if int(coord[i]) > x_vst:
			x_vst = int(coord[i]) - int(dest)
			res += 1
	if i != int(c_count) - 1 and int(coord[i]) + 2 * int(dest) <= int(coord[i + 1]):
		x_vst = int(coord[i]) + int(dest)
		res += 1
	if i == int(c_count) - 1:
		x_vst = int(coord[i]) + int(dest)
		res += 1
print(res)


(n, d) = list(map(int, input().split()))
x = list(map(int, input().split()))
pog = 2
for i in range(len(x) - 1):
	if abs(x[i] - x[i + 1]) > 2 * d:
		pog = pog + 2
	elif abs(x[i] - x[i + 1]) == 2 * d:
		pog = pog + 1
print(pog)


(n, d) = [int(v) for v in input().split()]
a = {int(v) for v in input().split()}
b1 = {v - d for v in a}
b2 = {v + d for v in a}
s = (b1 | b2) - a
s = {v for v in b1 | b2 if min((abs(v - vv) for vv in a)) == d}
print(len(s))


(n, d) = map(int, input().split())
x = [int(l) for l in input().split()]
k = 0
for i in range(len(x)):
	if i == 0:
		k += 1
	if i == len(x) - 1:
		k += 1
	elif x[i + 1] - x[i] > 2 * d:
		k += 2
	elif x[i + 1] - x[i] == 2 * d:
		k += 1
print(k)


rd = lambda : list(map(int, input().split()))
(n, d) = rd()
a = rd()
print(2 + sum(([2 - (y - x == 2 * d), 0][y - x < 2 * d] for (x, y) in zip(a, a[1:]))))


def scanf(t=int):
	return list(map(t, input().split()))
(n, d) = scanf()
m = scanf()
ans = sum([2 - (m[i] - m[i - 1] == 2 * d) for i in range(1, n) if m[i] - m[i - 1] >= 2 * d])
print(ans + 2)


(n, d) = input().split()
n = int(n)
d = int(d)
a = [int(n) for n in input().split()]
o = []
r = 0
for i in range(len(a) - 1):
	o.append(a[i + 1] - a[i])
for j in range(len(o)):
	if o[j] > 2 * d:
		r += 2
	elif o[j] == 2 * d:
		r += 1
print(r + 2)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
l = set()
for i in a:
	x = i + d
	r = 100000000000
	for j in a:
		r = min(abs(x - j), r)
	if r == d:
		l.add(x)
	x = i - d
	r = 100000000000
	for j in a:
		r = min(abs(x - j), r)
	if r == d:
		l.add(x)
print(len(l))


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
a = []
c = 0
if n == 1:
	print('2')
	exit()
else:
	pass
if n >= 2:
	for i in range(n):
		try:
			if i == 0 or i == n - 1:
				c += 1
			if i != 0 and abs(l[i] - d - l[i - 1]) > d:
				c += 1
			if i != n - 1 and l[i + 1] - (l[i] + d) >= d:
				c += 1
		except:
			pass
print(c)


def solve():
	s = 2
	for i in range(1, len(x)):
		s += max(0, min(2, x[i] - x[i - 1] - 2 * d + 1))
	return s

def main():
	global n, d, x
	(n, d) = list(map(int, input().split()))
	x = list(map(int, input().split()))
	print(solve())
main()


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
c = 2
for i in range(n - 1):
	if abs(l[i] - l[i + 1]) > 2 * d:
		c += 2
	if abs(l[i] - l[i + 1]) == 2 * d:
		c += 1
print(c)


(n_hotels, distance) = map(int, input().split())
coordinates = list(map(int, input().split()))
ways = set()
for coordinate in coordinates:
	ways.add(coordinate - distance)
	ways.add(coordinate + distance)
ways_copy = ways.copy()
for way in ways_copy:
	for coordinate in coordinates:
		if abs(way - coordinate) < distance:
			ways.remove(way)
			break
print(len(ways))


def main():
	(n, d) = map(int, input().split())
	x = list(map(int, input().split()))
	ret = 2
	for i in range(n - 1):
		if x[i + 1] - x[i] >= 2 * d:
			ret += 1 + (x[i + 1] - x[i] >= 2 * d + 1)
	print(ret)
	return 0
main()


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

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

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

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = [2]
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(3, limit + 1, 2):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

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

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, d) = mp()
	l = li()
	if n == 1:
		print(2)
		return
	c = 2
	s = set()
	for i in range(1, n):
		x = l[i] - l[i - 1]
		if x > 2 * d:
			c += 2
		if x == 2 * d:
			c += 1
	print(c)
for _ in range(1):
	solve()


arr = list(input().split(' '))
(n, d) = (int(arr[0]), int(arr[1]))
arr = list(input().split(' '))
arr = list((int(x) for x in arr))
plus = [-d, d]
res = set()
for i in range(len(arr)):
	for adder in plus:
		cur = arr[i] + adder
		flag = True
		for j in range(len(arr)):
			if i == j:
				continue
			if cur == arr[j]:
				flag = False
		new_flag = True
		for j in range(len(arr)):
			if i == j:
				continue
			if abs(arr[j] - cur) < d:
				new_flag = False
		if flag and new_flag and (cur not in res):
			res.add(cur)
print(len(res))


(n, d) = map(int, input().split())
hot = [int(x) for x in input().split()]
tot = 2
for i in range(1, n):
	if hot[i] - hot[i - 1] >= 2 * d:
		tot += 2
	if hot[i] - hot[i - 1] == 2 * d:
		tot -= 1
print(tot)


(a, d) = map(int, input().split())
mass = list(map(int, input().split()))
cnt = 2
for i in range(0, a - 1):
	if mass[i + 1] - mass[i] > 2 * d:
		cnt += 2
	elif mass[i + 1] - mass[i] == 2 * d:
		cnt += 1
print(cnt)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
ans = 2
for i in range(len(l) - 1):
	gap = abs(l[i] - l[i + 1])
	if gap == 2 * d:
		ans += 1
	elif gap > 2 * d:
		ans += 2
print(ans)


(n, d) = tuple(map(int, input().split()))
hot = list(map(int, input().split()))
ans = 2
for i in range(n - 1):
	curr = hot[i]
	next = hot[i + 1]
	dum = abs(next - curr)
	if dum > 2 * d:
		ans += 2
	elif dum == 2 * d:
		ans += 1
print(ans)


(N, d) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = 2
for i in range(len(a) - 1):
	if abs(a[i + 1] - a[i]) == 2 * d:
		ans += 1
	elif abs(a[i + 1] - a[i]) > 2 * d:
		ans += 2
print(ans)


(n, d) = map(int, input().split())
A = list(map(int, input().split()))
B = set()
for i in A:
	a = i - d
	b = i + d
	f = 0
	g = 0
	for j in range(n):
		if A[j] == i:
			continue
		if abs(A[j] - a) < d:
			f = -1
		if abs(A[j] - b) < d:
			g = -1
	if f == 0:
		B.add(i - d)
	if g == 0:
		B.add(i + d)
print(len(B))


def i_ints():
	return map(int, input().split())
(n, d) = i_ints()
xs = list(i_ints())
count = 2
for i in range(n - 1):
	if xs[i] + 2 * d == xs[i + 1]:
		count += 1
	elif xs[i] + 2 * d < xs[i + 1]:
		count += 2
print(count)


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
res = set()
for el in x:
	xx = el + d
	r = 10 ** 10
	for ell in x:
		r = min(r, abs(xx - ell))
	if r == d:
		res |= {xx}
	xx = el - d
	r = 10 ** 10
	for ell in x:
		r = min(r, abs(xx - ell))
	if r == d:
		res |= {xx}
print(len(res))


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
if n == len(l):
	ans = []
	for i in range(0, len(l) - 1):
		ans.append(abs(l[i] - l[i + 1]))
	d_new = 2 * d
	count = 0
	for i in ans:
		if i - d_new > 0:
			count = count + 2
		elif i - d_new == 0:
			count = count + 1
		else:
			count = count
	print(count + 2)


(n, d) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
c = 0
for i in range(1, n):
	if arr[i] - arr[i - 1] == 2 * d:
		c += 1
	elif arr[i] - arr[i - 1] > 2 * d:
		c += 2
print(c + 2)


nd = input().split()
n = int(nd[0])
d = int(nd[1])
hotels = sorted([int(i) for i in input().split()])
count = 2
for i in range(len(hotels) - 1):
	count += min(max(hotels[i + 1] - hotels[i] - 2 * d + 1, 0), 2)
print(count)


import sys
from bisect import insort, bisect_right
data = sys.stdin.readlines()
lis = []
for line in data:
	lis.append(line)

def dist(i, j):
	return abs(i - j)
(n, d) = list(map(int, lis[0].split()))
seq = list(map(int, lis[1].split()))
if len(seq) == 1:
	print(2)
	sys.exit()
seq.sort()
candidates = [seq[0] - d]
cndt = seq[0] + d
if dist(cndt, seq[1]) >= d:
	candidates.append(cndt)
for i in range(1, len(seq) - 1):
	cndt = seq[i] - d
	if cndt != candidates[-1] and dist(cndt, seq[i - 1]) >= d and (dist(cndt, seq[i + 1]) >= d):
		candidates.append(cndt)
	cndt = seq[i] + d
	if cndt != candidates[-1] and dist(cndt, seq[i + 1]) >= d and (dist(cndt, seq[i - 1]) >= d):
		candidates.append(cndt)
cndt = seq[-1] - d
if dist(cndt, seq[-2]) >= d:
	candidates.append(cndt)
cndt = seq[-1] + d
candidates.append(cndt)
candidates = set(candidates)
candidates = sorted(list(candidates))
print(len(candidates))


from sys import stdin

def solve(x, d):
	x.sort()
	res = 2
	for i in range(1, len(x)):
		if x[i] - x[i - 1] > 2 * d:
			res += 2
		elif x[i] - x[i - 1] == 2 * d:
			res += 1
	print(res)
while True:
	try:
		(n, d) = map(int, input().split())
		x = list(map(int, input().split()))
		solve(x, d)
	except:
		break


(n, a) = map(int, input().split())
ar = []
count = 0
ar = list(map(int, input().split()))
for i in range(0, n - 1):
	if ar[i + 1] - ar[i] == 2 * a:
		count = count + 1
	elif ar[i + 1] - ar[i] > 2 * a:
		count = count + 2
count = count + 2
print(count)


(a, d) = map(int, input().split())
c = list(map(int, input().split()))
l = []
k = 0
for i in range(0, a):
	if i + 1 < a:
		l.append(abs(c[i] - c[i + 1]))
d = 2 * d
for i in range(0, len(l)):
	if l[i] >= d:
		k += 1
	if l[i] > d:
		k += 1
print(k + 2)


(n, d) = [int(x) for x in input().split()]
lst = [int(x) for x in input().split()]
s = 2
for i in range(n - 1):
	if abs(lst[i] - lst[i + 1]) > 2 * d:
		s += 2
	elif abs(lst[i] - lst[i + 1]) == 2 * d:
		s += 1
print(s)


read = lambda : map(int, input().split())
(n, d) = read()
x = sorted(list(read()))
ans = 2
for i in range(0, n - 1):
	if x[i + 1] - x[i] > 2 * d:
		ans += 2
	if x[i + 1] - x[i] == 2 * d:
		ans += 1
print(ans)


l = input().split()
n = int(l[0])
d = int(l[1])
a = input().split()
lis = []
count = 0
for i in range(0, len(a) - 1):
	temp1 = -1 * (int(a[i]) - int(a[i + 1]))
	temp1 = temp1 - 1
	temp1 = temp1 - 2 * (d - 1)
	if temp1 == 1:
		count = count + temp1
	if temp1 >= 2:
		count = count + 2
count = count + 2
print(count)


(n, d) = map(int, input().split())
arr = list(map(int, input().split()))
count = 2
for i in range(n - 1):
	if arr[i] + d < arr[i + 1] - d:
		count += 2
	if arr[i] + d == arr[i + 1] - d:
		count += 1
print(count)


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
t = 2
for i in range(1, n):
	f = a[i] - a[i - 1]
	if f == 2 * m:
		t += 1
	if f > 2 * m:
		t += 2
print(t)


(n, d) = map(int, input().split())
ls = list(map(int, input().split()))
count = 2
for i in range(n - 1):
	dist = ls[i + 1] - ls[i]
	if dist == d + d:
		count += 1
	elif dist > d + d:
		count += 2
print(count)


(n, d) = list(map(int, input().split()))
x = list(map(int, input().split()))
counter = 2
for k in range(n):
	if k == 0:
		continue
	cont = abs(-x[k] + x[k - 1]) // d
	if abs(-x[k] + x[k - 1]) == d * 2:
		counter += 1
	elif abs(-x[k] + x[k - 1]) > d * 2:
		counter += 2
	else:
		continue
print(counter)


info = input().split()
n = int(info[0])
d = int(info[1])
prev = input().split()
prevlist = [int(i) for i in prev]
new = 2
newlist = list(map(lambda x, y: y - x, prevlist, prevlist[1:]))
doubleresult = list(filter(lambda x: x > 2 * d, newlist))
singleresult = list(filter(lambda x: x == 2 * d, newlist))
new += len(doubleresult) * 2 + len(singleresult)
print(new)


(noh, d) = [int(x) for x in input().split()]
hotels = [int(x) for x in input().split()]
print(2 + sum([(b - a >= 2 * d) + (b - a > 2 * d) for (a, b) in zip(hotels, hotels[1:])]))


R = lambda : map(int, input().split())
(n, d) = R()
h = 2
a = R()
p = next(a)
for x in a:
	h += (x - p >= d * 2) + (x - p > d * 2)
	p = x
print(h)


(n, d) = map(int, input().split())
A = [0 for _ in range(n - 1)]
X = list(map(int, input().split()))
for i in range(n - 1):
	A[i] = X[i + 1] - X[i]
a = 2
for x in A:
	if x == 2 * d:
		a += 1
	elif x > 2 * d:
		a += 2
print(a)


[n, d] = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
res = 2
for i in range(1, n):
	v = a[i] - a[i - 1]
	if d * 2 < v:
		res += 2
	if d * 2 == v:
		res += 1
print(res)


(n, d) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
pos = 2
for i in range(n - 1):
	l = a[i] + d
	r = a[i + 1] - d
	if l == r:
		pos += 1
	elif l < r:
		pos += 2
print(pos)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
(n, d) = map(int, sys.stdin.readline().split(' '))
a = list(map(int, sys.stdin.readline().split(' ')))
count = 1
for i in range(1, len(a)):
	if abs(a[i] - a[i - 1]) == 2 * d:
		count += 1
	if abs(a[i] - a[i - 1]) > 2 * d:
		count += 2
if len(a) >= 1:
	count += 1
print(count)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


from bisect import bisect_left as bl, bisect_right as br

def readList(converter=str):
	return [converter(x) for x in input().strip().split()]
(n, d) = readList(int)
l = readList(int)
count = 0
for (i, el) in enumerate(l):
	if i > 0:
		lower = abs(l[i - 1] - (el - d))
		if d <= lower:
			count += 0.5 if lower == d else 1
	else:
		count += 1
	if i + 1 < n:
		upper = abs(l[i + 1] - (el + d))
		if d <= upper:
			count += 0.5 if upper == d else 1
	else:
		count += 1
print(int(count))


(n, d) = map(int, input().split())
li = list(map(int, input().split()))
c = 2
for i in range(1, n):
	if li[i] - li[i - 1] == 2 * d:
		c = c + 1
	if li[i] - li[i - 1] > 2 * d:
		c = c + 2
print(c)


(n, k) = map(int, input().split(' '))
positions = [int(i) for i in input().split(' ')]
possible = 2
for i in range(n - 1):
	if positions[i + 1] - positions[i] == k * 2:
		possible += 1
	elif positions[i + 1] - positions[i] > k * 2:
		possible += 2
print(possible)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(n):
	x = a[i] - d
	m = d
	for j in range(n):
		m = min(abs(a[j] - (a[i] - d)), m)
	if x not in a and x not in ans and (m == d):
		ans.append(x)
	x = a[i] + d
	m = d
	for j in range(n):
		m = min(abs(a[j] - (a[i] + d)), m)
	if x not in a and x not in ans and (m == d):
		ans.append(x)
print(len(ans))


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
	print(2)
else:
	ct = 0
	inv = 0
	for i in range(n):
		if i != 0:
			if a[i] - d >= a[i - 1] + d:
				ct += 1
			if a[i] - d == a[i - 1] + d:
				inv += 1
		if i != n - 1:
			if a[i] + d <= a[i + 1] - d:
				ct += 1
			if a[i] + d == a[i + 1] - d:
				inv += 1
	print(ct - inv // 2 + 2)


[n, d] = [int(i) for i in input().split()]
coords = [int(i) for i in input().split()]
count = 2
hotels = set()
if n > 1:
	for i in range(n):
		if i == 0:
			if coords[i + 1] - (coords[i] + d) >= d:
				if coords[i] + d not in hotels:
					count += 1
					hotels.add(coords[i] + d)
		elif i == n - 1:
			if coords[i] - d - coords[i - 1] >= d:
				if coords[i] - d not in hotels:
					count += 1
					hotels.add(coords[i] - d)
		else:
			if coords[i] - d - coords[i - 1] >= d:
				if coords[i] - d not in hotels:
					count += 1
					hotels.add(coords[i] - d)
			if coords[i + 1] - (coords[i] + d) >= d:
				if coords[i] + d not in hotels:
					count += 1
					hotels.add(coords[i] + d)
else:
	pass
print(count)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ka = 2
for i in range(n - 1):
	if l[i + 1] - l[i] == 2 * k:
		ka = ka + 1
	elif l[i + 1] - l[i] > 2 * k:
		ka += 2
print(ka)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
ck = []
for i in a:
	ck.append(i - d)
	ck.append(i + d)
c = list(set(ck))
ans = len(c)
for i in c:
	m = 11212122212
	for j in a:
		m = min(m, abs(i - j))
	if m < d:
		ans -= 1
print(ans)


(n, d) = list(map(int, input().split()))
X = list(map(int, input().split()))
ans = []
for i in range(n):
	if i == 0:
		ans.append(X[i] - d)
	elif ans[-1] > X[i] - d:
		ans.pop()
	elif X[i] - d > X[i - 1] + d:
		ans.append(X[i] + d)
	ans.append(X[i] + d)
print(len(ans))


import math
(n, d) = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == 1:
	print(2)
	exit()
ans = 2
for x in range(n - 1):
	diff = abs(a[x] - a[x + 1])
	if diff / 2 >= d:
		ans += 1
		if diff / 2 > d:
			ans += 1
print(ans)


(n, k) = list(map(int, input().split()))
kx = list(map(int, input().split()))
co = 0
for x in range(len(kx) - 1):
	ifs = abs(kx[x] - kx[x + 1])
	ta = ifs / k
	if ta == 2:
		co += 1
	elif ta > 2:
		co += 2
	else:
		pass
print(co + 2)


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
(l, r) = ([x[i] - d for i in range(n)], [x[i] + d for i in range(n)])
lr = set(l) | set(r)
ans = 0
for lri in lr:
	if min(list(map(lambda y: abs(lri - y), x))) == d:
		ans += 1
print(ans)


def main():
	(n, d) = map(int, input().split())
	x = tuple(map(int, input().split()))
	count = 2
	prev = x[0]
	d2 = 2 * d
	for h in x[1:]:
		dist = h - prev
		if dist == d2:
			count += 1
		elif dist > d2:
			count += 2
		prev = h
	print(count)
main()


nd = list(map(int, input().strip().split()))
n = nd[0]
d = nd[1]
lst = list(map(int, input().split()))
count = 2
if n != 1:
	for i in range(n - 1):
		if lst[i + 1] - lst[i] == 2 * d:
			count += 1
		elif lst[i + 1] - lst[i] > 2 * d:
			count += 2
print(count)


[n, d] = list(map(int, input().split()))
X = list(map(int, input().split()))
nb = 0
last = X[0] - d - 1
for i in range(n):
	if i != 0:
		if X[i] - d - X[i - 1] >= d and X[i] - d > last:
			nb += 1
			last = X[i] - d
	else:
		nb += 1
	if i != n - 1:
		if -X[i] - d + X[i + 1] >= d and X[i] + d > last:
			nb += 1
			last = X[i] + d
	else:
		nb += 1
print(nb)


(n, d) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
l1 = []
for i in range(n):
	l1.extend([l[i] + d, l[i] - d])
l1 = list(set(l1))
l1.sort()
ct = 0
for j in range(len(l1)):
	ct1 = 0
	for i in range(n):
		if abs(l1[j] - l[i]) < d:
			ct1 = 1
			break
	if ct1 == 0:
		ct += 1
print(ct)


import sys
n_and_c = input()
nc = n_and_c.split()
n = int(nc[0])
c = int(nc[1])
v = []
solution = 0
vstr = input()
vstr = vstr.split(' ')
for i in range(0, n):
	v.append(int(vstr[i]))
v.sort()
for i in range(0, int(n - 1)):
	if v[i + 1] - v[i] - 2 * c >= 1:
		solution += 2
	if v[i + 1] - v[i] - 2 * c == 0:
		solution += 1
print(solution + 2)


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
c = 2
z = {}
for i in range(0, n - 1):
	if a[i] + k < a[i + 1] - k:
		c = c + 2
	if a[i] + k == a[i + 1] - k:
		c = c + 1
print(c)


(n1, d1) = input().split(' ')
n = int(n1)
d = int(d1)
a1 = [0] * n
a = [0] * n
s = 2
a1 = input().split(' ')
for i in range(n):
	a[i] = int(a1[i])
	if i > 0 and i < n:
		if a[i - 1] + d * 2 == a[i]:
			s += 1
		elif a[i - 1] + d * 2 < a[i]:
			s += 2
print(s)


(n, d) = input().split()
n = int(n)
d = int(d)
a = [int(x) for x in input().split()]
count = 2
for i in range(n - 1):
	if a[i + 1] - a[i] > 2 * d:
		count += 2
	elif a[i + 1] - a[i] == 2 * d:
		count += 1
print(count)


from sys import stdin

def solve(tc):
	(n, d) = map(int, stdin.readline().split())
	li = list(map(int, stdin.readline().split()))
	ans = 2
	for i in range(1, n):
		if li[i] - li[i - 1] > d + d:
			ans += 2
		elif li[i] - li[i - 1] == d + d:
			ans += 1
	print(ans)
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip()) if LOCAL_TEST else 1
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


input1 = input()
n = int(input1.split()[0])
d = int(input1.split()[1])
coor = [int(num) for num in input().split()]
sum = 0
for i in range(n - 1):
	if coor[i + 1] - coor[i] == 2 * d:
		sum = sum + 1
	if coor[i + 1] - coor[i] > 2 * d:
		sum = sum + 2
print(sum + 2)


(n, d) = map(int, input().split())
li = list(map(int, input().split()))
ans = 0
for i in range(n):
	r = li[i]
	if i != 0:
		if r - d > l + d:
			ans += 2
			l = r
		elif r - d == l + d:
			ans += 1
			l = r
	l = r
print(ans + 2)


end = pow(10, 9)

def main():
	(n, d) = [int(x) for x in input().split()]
	hotels = [int(x) for x in input().split()]
	c = 0
	last = 0
	for i in range(n):
		if i == 0:
			c += 1
			last = hotels[i] - d
		if i == n - 1:
			c += 1
		if i != 0 and hotels[i] - hotels[i - 1] >= 2 * d and (hotels[i] - d > last):
			c += 1
			last = hotels[i] - d
		if i != n - 1 and hotels[i] + 2 * d <= hotels[i + 1]:
			last = hotels[i] + d
			c += 1
	print(c)
main()


from collections import defaultdict

def solve():
	total = 2
	for i in range(n - 1):
		distance = abs(coords[i] - coords[i + 1])
		if distance > 2 * d:
			total += 2
		elif distance == 2 * d:
			total += 1
		else:
			continue
	return total
(n, d) = [int(x) for x in input().split(' ')]
coords = [int(x) for x in input().split(' ')]
hotels = defaultdict(int)
for i in range(n):
	hotels[coords[i]] = 1
print(solve())


(n, d) = map(int, input().split())
ls = list(map(int, input().split()))
ans = 2
d -= 1
d *= 2
for i in range(n - 1):
	if ls[i] < 0 and ls[i + 1] > 0:
		pd = 0 - ls[i] + ls[i + 1] - 1
		if pd - d > 0:
			if pd - d == 1:
				ans += pd - d
			else:
				ans += 2
	else:
		pd = abs(ls[i] - ls[i + 1]) - 1
		if pd - d > 0:
			if pd - d == 1:
				ans += pd - d
			else:
				ans += 2
print(ans)


a = list(map(int, input().split()))
n = a[0]
d = a[1]
x = list(map(int, input().split()))
count = 2
for i in range(len(x) - 1):
	if x[i + 1] - x[i] == 2 * d:
		count += 1
	elif x[i + 1] - x[i] > 2 * d:
		count += 2
print(count)


(n, dist) = map(int, input().split())
locs = list(map(int, input().split()))

def f(A):
	c = 0
	for (i, k) in enumerate(A):
		if i == 0 or k - dist >= A[i - 1] + dist:
			c += 1
		if i == len(A) - 1 or k + dist < A[i + 1] - dist:
			c += 1
	return c
ans = f(locs)
print(ans)


inp = input()
(n, k) = inp.split(' ')
(n, k) = (int(n), int(k))
a = input()
a = [int(i) for i in a.split()]
count = 2
for i in range(n - 1):
	if a[i] + k < a[i + 1] - k:
		count += 2
	elif a[i] + k == a[i + 1] - k:
		count += 1
print(count)


(n, d) = map(int, input().split())
hotels = list(map(int, input().split()))
count = 0
for i in range(1, n):
	back = hotels[i - 1] + d
	front = hotels[i] - d
	if front > back:
		count += 2
	elif front == back:
		count += 1
print(count + 2)


def f(arr, n, d):
	existing = set(arr)
	cnt = 0
	for (i, c) in enumerate(arr):
		city1 = c - d
		if city1 not in existing:
			if i == 0 or (i > 0 and abs(arr[i - 1] - city1) >= d):
				existing.add(city1)
				cnt += 1
		city2 = c + d
		if city2 not in existing:
			if i == n - 1 or (i < n - 1 and abs(city2 - arr[i + 1]) >= d):
				existing.add(city2)
				cnt += 1
	return cnt
(n, d) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
print(f(arr, n, d))


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
dd = 2 * d
ans = 2
for (i, el) in enumerate(x[:-1], 1):
	t = x[i] - el
	if t == dd:
		ans += 1
	elif t > dd:
		ans += 2
print(ans)


def hotels(lst, d):
	kol = 2
	(x, y) = (0, 0)
	for i in range(len(lst) - 1):
		x = lst[i] + d
		y = lst[i + 1] - d
		if x < y:
			kol += 2
		elif x == y:
			kol += 1
	return kol
(N, D) = [int(j) for j in input().split()]
a = [int(z) for z in input().split()]
print(hotels(a, D))


(n, d) = list(map(int, input().split()))
l = list(map(int, input().split()))
l = [-3000000000] + l
l.append(3000000000)
t = []
s = 0
for i in range(1, n + 1):
	if l[i] - l[i - 1] >= 2 * d:
		x = l[i] - d
		if l[i] - x <= x - l[i - 1] and (not x in t):
			t.append(x)
	if l[i + 1] - l[i] >= 2 * d:
		x = l[i] + d
		if x - l[i] <= l[i + 1] - x and (not x in t):
			t.append(x)
print(len(t))


(n, d) = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
Ans = 2
for i in range(1, n):
	if lst[i] - lst[i - 1] > 2 * d:
		Ans += 2
	elif lst[i] - lst[i - 1] == 2 * d:
		Ans += 1
print(Ans)


from sys import stdin, stdout
from collections import deque, Counter

def main():
	lprint = lambda *args: stdout.write(' '.join(map(str, args)) + '\n')
	(n, d) = map(int, stdin.readline().split())
	l = [int(i) for i in stdin.readline().split()]
	k = 0
	l = [abs(l[i] - l[i + 1]) for i in range(len(l) - 1)]
	for i in l:
		if i > 2 * d:
			k += 2
		elif i == 2 * d:
			k += 1
	print(k + 2)
main()


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
cands = set()
for x in a:
	cands.add(x - d)
	cands.add(x + d)
ans = 0
for x in cands:
	mn_dist = min(map(lambda t: abs(t - x), a))
	ans += mn_dist == d
print(ans)


nd = list(map(int, input().split(' ')))
d = nd[1]
y = list(map(int, input().split(' ')))
tt = 0
if len(y) > 1:
	for a in range(len(y)):
		m = y[a] - y[a - 1] - 2 * d
		if m < 0:
			continue
		elif m == 0:
			tt += 1
		else:
			tt += 2
print(tt + 2)


yoar = list(map(int, input().split()))
n = yoar[0]
d = yoar[1]
arr = list(map(int, input().split()))
arr.sort()
ans = 2
for i in range(1, n):
	x1 = arr[i - 1]
	x2 = arr[i]
	if x2 - x1 > 2 * d:
		ans += 2
	elif x2 - x1 == 2 * d:
		ans += 1
print(ans)


def input_int():
	return list(map(int, input().split()))
(n, k) = input_int()
arr = input_int()
from collections import defaultdict
vis = defaultdict(int)
ans = 2
for i in range(1, n):
	for d in [-1, 1]:
		if d == -1:
			cur = arr[i - 1] + k
		else:
			cur = arr[i] - k
		if abs(cur - arr[i - 1]) >= k and abs(cur - arr[i]) >= k:
			if vis[cur] == 0:
				vis[cur] = 1
				ans += 1
print(ans)


(n, d) = [int(s) for s in input().split(' ')]
x = [int(s) for s in input().split(' ')]
gaps = [x[i] - x[i - 1] for i in range(1, n)]
exact = gaps.count(2 * d)
bigger = len([gap for gap in gaps if gap > 2 * d])
ans = 2 + exact + 2 * bigger
print(ans)


(n, d) = map(int, input().split())
x = list(map(int, input().strip().split()))
c = 2
for i in range(0, n - 1):
	if x[i + 1] - x[i] > 2 * d:
		c = c + 2
	elif x[i + 1] - x[i] == 2 * d:
		c = c + 1
	else:
		continue
print(c)


import os

def sonya_and_hotels():
	cou = 2
	for (i, ele) in enumerate(range(len(arr) - 1)):
		if arr[i] + d <= arr[i + 1] - d:
			if arr[i] + d == arr[i + 1] - d:
				cou += 1
			else:
				cou += 2
	return cou
(size, d) = map(int, input().split())
arr = list(map(int, input().split()))
print(sonya_and_hotels())


(m, n) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 2
for i in range(m - 1):
	if a[i + 1] - a[i] > 2 * n:
		count += 2
	elif a[i + 1] - a[i] == 2 * n:
		count += 1
print(count)


nd = list(map(int, input().split(' ')))
n = nd[0]
d = nd[1]
a = list(map(int, input().split(' ')))
ans = 0
if n == 1:
	print('2')
	exit()
for i in range(len(a)):
	if i == 0:
		ans += 1
		if (a[i + 1] - a[i]) / d == 2:
			ans += 1
		elif (a[i + 1] - a[i]) / d > 2:
			ans += 2
	elif i == len(a) - 1:
		ans += 1
	elif (a[i + 1] - a[i]) / d == 2:
		ans += 1
	elif (a[i + 1] - a[i]) / d > 2:
		ans += 2
print(ans)


(n, m) = map(int, input().split())
inf = int(1000000000000.0)
ls = [int(i) for i in input().split()]
ls.sort()
ls = [-inf] + ls + [inf]
st = set()
for i in range(n + 1):
	if i != 0:
		if ls[i] + m < ls[i + 1] and ls[i + 1] - (ls[i] + m) >= m:
			st.add(ls[i] + m)
	if i != n:
		if ls[i + 1] - m > ls[i] and ls[i + 1] - m - ls[i] >= m:
			st.add(ls[i + 1] - m)
print(len(st))


(N, K) = map(int, input().split())
L = list(map(int, input().split()))
ans = 2
for i in range(N - 1):
	diff = L[i + 1] - L[i] - 1 - 2 * (K - 1)
	if diff == 1:
		ans = ans + diff
	elif diff > 1:
		ans = ans + 2
print(ans)


(n, d) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ct = 2
for i in range(len(a) - 1):
	if a[i] + d < a[i + 1] - d:
		ct += 2
	elif a[i] + d == a[i + 1] - d:
		ct += 1
print(ct)


I = input
(n, d) = map(int, I().split())
d *= 2
v = list(map(int, I().split()))
x = 2
for i in range(n - 1):
	r = v[i + 1] - v[i]
	if r == d:
		x += 1
	elif r > d:
		x += 2
print(x)


(n, m) = [int(el) for el in input().split()]
col = 2
a = [int(el) for el in input().split()]
for i in range(n - 1):
	if a[i + 1] - a[i] == m * 2:
		col += 1
	if a[i + 1] - a[i] > m * 2:
		col += 2
print(col)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
t = 2
for i in range(1, n):
	di = a[i] - a[i - 1]
	if di == 2 * m:
		t += 1
	if di > 2 * m:
		t += 2
print(t)


(n, k) = input().split()
ls = list(map(float, input().split()))
n = int(n)
k = int(k)
ans = 2
for i in range(1, n):
	if ls[i] - k > ls[i - 1] + k:
		ans += 2
	elif ls[i] - k == ls[i - 1] + k:
		ans += 1
print(ans)


import sys
input = sys.stdin.readline
(n, d) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
c = 2
for i in range(1, n):
	if x[i] - x[i - 1] > 2 * d:
		c += 2
	elif x[i] - x[i - 1] == 2 * d:
		c += 1
print(c)


temp = [int(x) for x in input().split()]
(x, d) = (temp[0], temp[1])
arr = [int(x) for x in input().split()]
total_points = 2
for i in range(1, len(arr)):
	if arr[i] - arr[i - 1] > 2 * d:
		total_points += 2
	elif arr[i] - arr[i - 1] >= 2 * d:
		total_points += 1
print(total_points)


(n, d) = map(int, input().split())
p = None
r = 2
for i in map(int, input().split()):
	if p != None:
		if i - p > 2 * d:
			r += 2
		elif i - p == 2 * d:
			r += 1
	p = i
print(r)


cities_to_build = []

def check_city_asc(city_asc, cities, i, d):
	if not city_asc in cities and city_asc not in cities_to_build:
		if i + 1 < len(cities) and cities[i + 1] - city_asc >= d:
			cities_to_build.append(city_asc)
			return True
		elif i + 1 < len(cities) and cities[i + 1] - city_asc < d:
			return False
		elif i - 1 >= 0 and city_asc - cities[i - 1] > d:
			cities_to_build.append(city_asc)
			return True
		elif i - 1 >= 0 and city_asc - cities[i - 1] > d:
			return False
		elif i - 1 < 0 and cities[i + 1] - city_asc >= d:
			cities_to_build.append(city_asc)
			return True
		elif i + 1 >= len(cities):
			cities_to_build.append(city_asc)
			return True
	return False

def check_city_dsc(city_dsc, cities, i, d):
	if not city_dsc in cities and city_dsc not in cities_to_build:
		if i - 1 >= 0 and city_dsc - cities[i - 1] >= d:
			cities_to_build.append(city_dsc)
			return True
		elif i - 1 >= 0 and city_dsc - cities[i - 1] < d:
			return False
		elif i + 1 < len(cities) and cities[i + 1] - city_dsc > d:
			cities_to_build.append(city_dsc)
			return True
		elif i + 1 < len(cities) and cities[i + 1] - city_dsc < d:
			return False
		elif i + 1 >= len(cities) and city_dsc - cities[i - 1] >= d:
			cities_to_build.append(city_dsc)
			return True
		elif i - 1 < 0:
			cities_to_build.append(city_dsc)
			return True
	return False

def main():
	(n, d) = map(int, input().split())
	cities = list(map(int, input().split()))
	ans = 0
	if n == 1:
		print(2)
		return
	for i in range(0, len(cities)):
		city_asc = cities[i] + d
		city_dsc = cities[i] - d
		if check_city_asc(city_asc, cities, i, d):
			ans += 1
		if check_city_dsc(city_dsc, cities, i, d):
			ans += 1
	print(ans)
main()


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
l.append(999999999999)
e = 0
for i in range(a):
	w = l[i + 1]
	r = l[i]
	if w - r > 2 * b:
		e += 2
	if w - r == 2 * b:
		e += 1
print(e)


import math

def problem(in1, in2):
	inp1 = list(map(int, in1.split()))
	n = inp1[0]
	min_dist = inp1[1]
	points = list(map(int, in2.split()))
	result = 2
	min_gap = min_dist * 2 - 1
	for (i, point) in enumerate(points[1:]):
		dist = point - points[i]
		possible = dist - min_gap
		if possible == 1:
			result += 1
		if possible >= 2:
			result += 2
	return result
in1 = input()
in2 = input()
result = problem(in1, in2)
print(result)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
x = []
count = 0
for i in range(n - 1):
	if abs(l[i + 1] - l[i]) == 2 * d:
		count += 1
	elif abs(l[i + 1] - l[i]) > 2 * d:
		count += 2
print(count + 2)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
ans = 2
for i in range(1, n):
	d1 = abs(a[i] - a[i - 1])
	if d < d1 / 2:
		ans += 2
	elif d == d1 / 2:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
o = 2
for i in range(n):
	if i + 1 == n:
		break
	d = abs(l[i] - l[i + 1]) / k
	if d == 2:
		o += 1
	elif d > 2:
		o += 2
print(o)


from sys import stdin, stdout
(n, d) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
z = [a[0] - d]
z.append(a[-1] + d)
for i in range(1, n - 1):
	if abs(a[i] - (a[i - 1] + d)) >= d:
		z.append(a[i] - d)
	if abs(a[i] - (a[i + 1] - d)) >= d:
		z.append(a[i] + d)
if n > 1:
	if abs(a[0] - (a[1] - d)) >= d:
		z.append(a[0] + d)
	if abs(a[-1] - (a[-2] + d)) >= d:
		z.append(a[-1] - d)
z = set(z)
print(len(z))


(n, d) = [int(x) for x in input().split()]
hotels = [int(x) for x in input().split()]
k = 2
for i in range(len(hotels) - 1):
	g = hotels[i + 1] - hotels[i]
	if g - d >= d:
		if hotels[i + 1] - d == hotels[i] + d:
			k += 1
		else:
			k += 2
print(k)


(n, d) = input().split()
n = int(n)
d = int(d)
a = list(map(int, input().split()))
t = 2
for i in range(n - 1):
	if a[i + 1] - a[i] > 2 * d:
		t += 2
	elif a[i + 1] - a[i] == 2 * d:
		t += 1
print(t)


(n, d) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
ans = 2
for i in range(1, len(x)):
	if x[i] - x[i - 1] == 2 * d:
		ans += 1
	if x[i] - x[i - 1] > 2 * d:
		ans += 2
print(ans)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
count = 2
a.sort()
for i in range(len(a) - 1):
	if abs(a[i] - a[i + 1]) > 2 * d:
		count += 2
	elif d * 2 == abs(a[i] - a[i + 1]):
		count += 1
print(count)


X = list(map(int, input().split()))
Houses = list(map(int, input().split()))
NUM = 0
for i in range(len(Houses) - 1):
	if abs(Houses[i + 1] - Houses[i]) >= 2 * X[1]:
		NUM += 1 if abs(Houses[i + 1] - Houses[i]) == 2 * X[1] else 2
print(NUM + 2)


(n, k) = input().split()
n = int(n)
k = int(k)
lis = list(map(int, input().split()))
places = []
ans = 0
for i in range(0, n):
	if i != 0:
		if lis[i - 1] <= lis[i] - 2 * k:
			if lis[i] - k not in places:
				ans += 1
				places.append(lis[i] - k)
	else:
		ans += 1
	if i != n - 1:
		if lis[i + 1] >= lis[i] + 2 * k:
			if lis[i] + k not in places:
				ans += 1
				places.append(lis[i] + k)
	else:
		ans += 1
print(ans)


(n, d) = map(int, input().split())
list = [int(i) for i in input().split()]
output = 1
if n == 1:
	print('2')
	exit()
if list[0] + d <= list[1] - d:
	output += 1
for i in range(1, n - 1):
	if list[i] + d <= list[i + 1] - d:
		output += 1
	if list[i] - d > list[i - 1] + d:
		output += 1
if list[n - 1] - d > list[n - 2] + d:
	output += 1
output += 1
print(output)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
k = []
for i in range(n - 1):
	r = abs(l[i + 1] - l[i])
	if r / m > 2:
		k.append(int(2))
	elif int(r / m) == 2:
		k.append(int(1))
print(sum(k) + 2)


(n, d) = input().split()
n = int(n)
d = int(d)
l = input().split()
elem2 = 'a'
k = False
ans = 0
for elem in l:
	if k:
		if int(elem) - int(elem2) > 2 * d:
			ans = ans + 2
		elif int(elem) - int(elem2) == 2 * d:
			ans = ans + 1
	k = True
	elem2 = elem
print(ans + 2)


(n, d) = (int(x) for x in input().split())
x = [int(x) for x in input().split()]
r = 2
for i in range(1, len(x)):
	if x[i] - x[i - 1] > 2 * d:
		r += 2
	elif x[i] - x[i - 1] == 2 * d:
		r += 1
print(r)


(m, n) = map(int, input().split())
s = [int(v) for v in input().split()]
count = 2
for i in range(len(s) - 1):
	val = abs(s[i] - s[i + 1]) / (n * 2)
	if val == 1:
		count += 1
	elif val > 1:
		count += 2
	else:
		count += 0
print(count)


read = lambda : map(int, input().split())
(n, d) = read()
x = sorted(read())
ans = 2
for i in range(1, n):
	dx = x[i] - x[i - 1]
	if dx == 2 * d:
		ans += 1
	elif dx > 2 * d:
		ans += 2
print(ans)


(n, d) = map(int, input().split())
arr = list(map(int, input().split()))
ans = 2
for i in range(1, n):
	diff = arr[i] - arr[i - 1] - 2 * d
	if not diff:
		ans += 1
	elif diff > 0:
		ans += 2
print(ans)


a = [int(i) for i in input().split()]
n = a[0]
d = a[1]
a = [int(i) for i in input().split()]
a.sort()
diff = []
for i in range(1, n):
	diff.append(abs(a[i] - a[i - 1]))
count = 2
for i in range(n - 1):
	if diff[i] == 2 * d:
		count += 1
	if diff[i] > 2 * d:
		count += 2
print(count)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
ans = 2
for i in range(n - 1):
	k = a[i + 1] - a[i] - 2 * d
	if k == 0:
		ans += 1
	elif k > 0:
		ans += 2
print(ans)


(n, d) = map(int, input().split())
n += 2
k = 0
s = set()
a = [-(10 ** 100 + 1)] + list(map(int, input().split())) + [10 ** 100 + 1]
for i in range(1, n - 1):
	elem = a[i] - d
	if elem - a[i - 1] >= d:
		s.add(elem)
	elem = a[i] + d
	if a[i + 1] - elem >= d:
		s.add(elem)
print(len(s))


(n, d) = map(int, input().split())
a = [int(_) for _ in input().split()]
c = 2
for i in range(n - 1):
	if (a[i + 1] - a[i]) / d > 2:
		c += 2
	elif (a[i + 1] - a[i]) / d == 2:
		c += 1
print(c)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
s = set(l)
ans = 2
for i in range(n - 1):
	if l[i + 1] - l[i] > 2 * d:
		ans += 2
	elif l[i + 1] - l[i] == 2 * d:
		ans += 1
print(ans)


(n, d) = [int(x) for x in input().split()]
l = list()
p = list()
l = [int(x) for x in input().split()]
ans = 2
for i in range(0, n):
	if i != 0:
		if l[i] - d - l[i - 1] >= d and i != 0:
			p.append(l[i] - d)
	if i != n - 1:
		if l[i + 1] - l[i] - d >= d and i != n - 1:
			p.append(d + l[i])
t = set(p) - set(l)
ans = ans + len(t)
print(ans)


(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
ct = 0
arr.sort()
for i in range(1, n):
	dif = arr[i] - arr[i - 1]
	if dif / q == 2:
		ct += 1
	elif dif / q > 2:
		ct += 2
print(ct + 2)


(n, d) = map(int, input().split())
c = list(map(int, input().split()))
cpt = 0
for k in range(1, n):
	r = c[k] - c[k - 1]
	if r - 2 * d == 0:
		cpt += 1
	elif r - 2 * d > 0:
		cpt += 2
print(cpt + 2)


[n, d] = [int(i) for i in input().strip().split()]
hotels = [int(i) for i in input().strip().split()]
ans = 0
built = set()
for hotel in hotels:
	newHotel = hotel + d
	minDist = d
	for h in hotels:
		minDist = min(minDist, abs(h - newHotel))
	if minDist == d and newHotel not in built:
		ans += 1
		built.add(newHotel)
	newHotel = hotel - d
	minDist = d
	for h in hotels:
		minDist = min(minDist, abs(h - newHotel))
	if minDist == d and newHotel not in built:
		ans += 1
		built.add(newHotel)
print(ans)


(totalHotels, distance) = list(map(int, input().split(' ')))
hotels = list(map(int, input().split(' ')))
newHotels = 2
for i in range(totalHotels - 1):
	space = hotels[i + 1] - hotels[i] - 2 * distance
	if space == 0:
		newHotels += 1
	elif space > 0:
		newHotels += 2
print(newHotels)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l2 = []
l = sorted(l)
c = 2
for i in range(len(l) - 1):
	if l[i + 1] - l[i] == 2 * k:
		c += 1
	elif l[i + 1] - l[i] > 2 * k:
		c += 2
print(c)


(n, d) = map(int, input().strip().split(' '))
values = [int(n) for n in input().split(' ')]
counter = 2
for i in range(len(values) - 1):
	if values[i] + d < values[i + 1] - d:
		counter += 2
	elif values[i] + d == values[i + 1] - d:
		counter += 1
	else:
		continue
print(counter)


(n, d) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
t = 2
for i in range(n - 1):
	z = x[i + 1] - x[i]
	if z >= 2 * d:
		if z == 2 * d:
			t += 1
		else:
			t += 2
print(t)


(n, d) = map(int, input().split())
cnt = 2
a = [int(y) for y in input().split()]
if n == 1:
	print('2')
else:
	for i in range(1, n):
		if a[i] - a[i - 1] == d * 2:
			cnt += 1
		elif a[i] - a[i - 1] > d * 2:
			cnt += 2
	print(cnt)


import sys
(n, d) = map(int, sys.stdin.readline().split())
hotel = list(map(int, sys.stdin.readline().split()))
t = 2
for loop in range(n):
	if loop != 0 and hotel[loop] - d > hotel[loop - 1] + d:
		t += 1
	if loop != n - 1 and hotel[loop] + d <= hotel[loop + 1] - d:
		t += 1
print(t)


(n, d) = input().split()
n = int(n)
d = int(d)
cnt = 2
cnt = int(cnt)
arr = list(map(int, input().split()))
arr = sorted(arr)
for i in range(1, n):
	if arr[i] - arr[i - 1] == 2 * d:
		cnt += 1
	if arr[i] - arr[i - 1] > 2 * d:
		cnt += 2
print(cnt)


(n, d) = map(int, input().split())
l1 = list([int(x) for x in input().split()])
l1.sort(reverse=True)
count = 0
for i in range(n - 1):
	if l1[i] - l1[i + 1] > 2 * d:
		count += 2
	if l1[i] - l1[i + 1] == 2 * d:
		count += 1
print(count + 2)


(n, k) = [int(j) for j in input().split()]
h = [int(j) for j in input().split()]
hp = [j + k for j in h]
hs = [j - k for j in h]
x = []
for i in range(n - 1):
	if abs(hp[i] - h[i + 1]) >= k:
		x.append(hp[i])
x.append(hp[n - 1])
x.append(hs[0])
for i in range(n - 1):
	if abs(hs[i + 1] - h[i]) >= k:
		x.append(hs[i + 1])
print(len(set(x)))


[n, d] = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
res = 2
for i in range(1, n):
	l = a[i - 1] + d
	r = a[i] - d
	res += (l <= r) + (l < r)
print(res)


(a, b) = map(int, input().split())
k = list(map(int, input().split()))
c = 2
for i in range(a - 1):
	z = abs(k[i] - k[i + 1])
	c += 2 if z > 2 * b else 1 if z == 2 * b else 0
print(c)


from __future__ import print_function
import sys
import math
import os.path
import random
from copy import deepcopy
from functools import reduce
from collections import Counter, ChainMap, defaultdict
from itertools import cycle, chain
from queue import Queue, PriorityQueue
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, nlargest, nsmallest
import bisect
from statistics import mean, mode, median, median_low, median_high
sys.setrecursionlimit(10 ** 9)

def log(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

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

def nio(offset):
	return map(lambda x: int(x) + offset, input().split())

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

def toString(aList, sep=' '):
	return sep.join((str(x) for x in aList))

def toMapInvertIndex(aList):
	return {k: v for (v, k) in enumerate(aList)}

def sortId(arr):
	return sorted(range(arr), key=lambda k: arr[k])
(n, d) = ni()
a = nia()
s = set([])
for ai in a:
	s.add(ai - d)
	s.add(ai + d)

def check(x):
	for ai in a:
		if abs(ai - x) < d:
			return False
	return True
count = 0
for si in s:
	if check(si):
		count += 1
print(count)


(n, d) = map(int, input().split())
daf = list(map(int, input().split()))
cand = set()
lim = 1000000000.0
for x in daf:
	l = x - d
	r = x + d
	cand.add(l)
	cand.add(r)
reject = set()
for x in cand:
	for y in daf:
		if y - d < x < y + d:
			reject.add(x)
			break
print(len(cand - reject))


(n, d) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
cnt = 2
for i in range(n):
	if i != n - 1 and a[i] + d <= a[i + 1] - d:
		cnt += 1
	if i != 0 and a[i] - d > a[i - 1] + d:
		cnt += 1
print(cnt)


(n, d) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
cnt = 2
for i in range(n - 1):
	cnt += 2 if abs(x[i] - x[i + 1]) > 2 * d else 1 if abs(x[i] - x[i + 1]) == 2 * d else 0
print(cnt)


from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from collections import defaultdict
import math
from random import random
cin = stdin.readline

def cout(x):
	stdout.write(str(x) + '\n')

def var(type=int):
	return type(stdin.readline())

def readline(type=int):
	return map(type, stdin.readline().split())

def readlist(type=int):
	return list(map(type, stdin.readline().split()))

def sorted_indexes(arr):
	return sorted(range(len(arr)), key=arr.__getitem__)

def printr(arr):
	[stdout.write(str(x) + ' ') for x in arr]
	cout('')

def find_lt(a, x):
	i = bisect_left(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return a[i]
	raise ValueError

def dist(x, y):
	return math.sqrt(x * x + y * y)

def binary_search(arr, x):
	i = bisect_left(arr, x)
	if i == len(arr) or arr[i] != x:
		return -1
	return i
(n, d) = readline()
a = readlist()
mp = {}
for i in range(n):
	left = a[i] - d
	right = a[i] + d
	if i == 0:
		mp[left] = 1
	elif abs(left - a[i - 1]) >= d:
		mp[left] = 1
	else:
		pass
	if i == n - 1:
		mp[right] = 1
	elif abs(right - a[i + 1]) >= d:
		mp[right] = 1
	else:
		pass
print(len(mp))


import math
(n, d) = map(int, input().split())
x = list(map(int, input().split()))
cnt = 2
for i in range(n - 1):
	dif = abs(x[i] - x[i + 1])
	if dif == 2 * d:
		cnt += 1
	elif dif > 2 * d:
		cnt += 2
print(cnt)


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	(n, d) = inar()
	arr = inar()
	arr.sort()
	ans = 0
	check = set()
	for i in range(n):
		lol = arr[i] + d
		if lol not in check and i + 1 < n and (lol < arr[i + 1]) and (arr[i + 1] - lol >= d):
			ans += 1
			check.add(lol)
		lol = arr[i] - d
		if lol not in check and i - 1 > -1 and (lol > arr[i - 1]) and (lol - arr[i - 1] >= d):
			ans += 1
			check.add(lol)
	print(ans + 2)
main()


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = set()
for i in range(0, n):
	x = l[i] - k
	y = l[i] + k
	if i < n - 1:
		if y <= l[i + 1] - k:
			s.add(y)
	if i > 0:
		if x >= l[i - 1] + k:
			s.add(x)
print(len(s) + 2)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
(r, c) = (0, 2)
for i in range(n - 1):
	r = abs(a[i] - a[i + 1])
	if r > 2 * d:
		c += 2
	if r == 2 * d:
		c += 1
print(c)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
ans = 2
a.sort()
for i in range(n - 1):
	ans += (a[i + 1] - a[i] > 2 * d) * 2 + (a[i + 1] - a[i] == 2 * d)
print(ans)


import math

def main_function():
	(n, d) = [int(i) for i in input().split(' ')]
	cities = [int(i) for i in input().split(' ')]
	count = 2
	current_city = cities[0]
	for i in cities:
		if i - current_city - 2 * d == 0:
			count += 1
		elif i - current_city - 2 * d > 0:
			count += 2
		current_city = i
	return count
print(main_function())


(x, y) = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
for i in range(0, x - 1):
	d = l[i + 1] - l[i] - 1
	e = 2 * (y - 1)
	if d > e:
		if d - e > 2:
			ans = ans + 2
		else:
			ans = ans + (d - e)
print(ans + 2)


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))
(n, d) = IL()
X = IL()
print(2 + sum(((x2 - x1 >= 2 * d) + (x2 - x1 > 2 * d) for (x1, x2) in zip(X[:-1], X[1:]))))


(n, d) = map(int, input().split())
(h, count) = (list(map(int, input().split())), 0)
for i in range(n - 1):
	if h[i] + d == h[i + 1] - d:
		count += 1
	if h[i] + d < h[i + 1] - d:
		count += 2
print(count + 2)


(n, d) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
an = 2
for i in range(len(A) - 1):
	s = A[i + 1] - A[i]
	if s > 2 * d:
		an += 2
	elif s == 2 * d:
		an += 1
print(an)


(n, d) = map(int, input().split())
arr = list(map(int, input().split()))
if n == 1:
	ans = 2
else:
	s = set()
	s.add(arr[0] - d)
	s.add(arr[-1] + d)
	for i in range(n):
		if i == 0:
			if arr[i + 1] - arr[i] - d >= d:
				s.add(arr[i] + d)
		elif i == n - 1:
			if arr[i] - d - arr[i - 1] >= d:
				s.add(arr[i] - d)
		else:
			if arr[i + 1] - arr[i] - d >= d:
				s.add(arr[i] + d)
			if arr[i] - d - arr[i - 1] >= d:
				s.add(arr[i] - d)
	ans = len(s)
print(ans)


import sys
import math
import bisect
import itertools

def main():
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	ans = 2
	for i in range(1, n):
		if A[i] - A[i - 1] == 2 * m:
			ans += 1
		elif A[i] - A[i - 1] > 2 * m:
			ans += 2
	print(ans)
main()


(n, d) = map(int, input().split())
s = list(map(int, input().split()))
places = 2
for i in range(len(s) - 1):
	if s[i + 1] - s[i] >= 2 * d:
		a1 = s[i + 1] - d
		a2 = s[i] + d
		if a1 == a2:
			places += 1
		else:
			places += 2
print(places)


(n, d) = [int(i) for i in input().split(' ')]
arr = [int(i) for i in input().split(' ')]
ans = 0
for i in range(n - 1):
	if arr[i + 1] - arr[i] - 2 * d == 0:
		ans += 1
	elif arr[i + 1] - arr[i] - 2 * d > 0:
		ans += 2
print(ans + 2)


(n, d) = input().split(' ')
a = input().split(' ')
j = 2
n = int(n)
d = int(d)
z = 2 * d
s = set()
for i in range(n - 1):
	if int(a[i + 1]) - int(a[i]) >= z:
		s.add(str(int(a[i]) + d))
		s.add(str(int(a[i + 1]) - d))
print(len(s) + 2)


(n, d) = map(int, input().split())
k = list(map(int, input().split()))
l1 = []
l1.append(k[0] - d)
for val in range(1, len(k) - 1):
	sp = k[val] + d
	if abs(k[val + 1] - sp) >= d:
		l1.append(sp)
	sp = k[val] - d
	if abs(sp - k[val - 1]) >= d:
		l1.append(sp)
kl = k[0] + d
if len(k) >= 2:
	if abs(k[1] - kl) >= d:
		l1.append(kl)
kl = k[len(k) - 1] - d
if len(k) >= 2:
	if abs(kl - k[len(k) - 2]) >= d:
		l1.append(kl)
l1.append(k[len(k) - 1] + d)
print(len(set(l1)))


TN = 1

def solution():
	(n, d) = map(int, input().split())
	x = list(map(int, input().split()))
	ans = 2
	for i in range(n - 1):
		if x[i] + d < x[i + 1] - d:
			ans += 2
		elif x[i] + d == x[i + 1] - d:
			ans += 1
	print(ans)
while TN != 0:
	solution()
	TN -= 1


import math
(n, d) = [int(x) for x in input().split(' ')]
pos = [int(x) for x in input().split(' ')]
count = 2
for i in range(1, n):
	if math.fabs(pos[i] - pos[i - 1]) > 2 * d:
		count += 2
	elif math.fabs(pos[i] - pos[i - 1]) == 2 * d:
		count += 1
	else:
		continue
print(count)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
counter = 2
for i in range(len(l)):
	try:
		t0 = l[i] + d
		t1 = l[i + 1] - d
		if l[i + 1] - t0 >= d:
			counter += 1
		if t1 - l[i] >= d and t0 != t1:
			counter += 1
	except:
		pass
print(counter)


input3 = input()
(n, d) = input3.split(' ')
n = int(n)
d = int(d)
input2 = input()
ln = input2.split(' ')
ln2 = []
for i in ln:
	ln2.append(int(i))
count = 2
c = 0
c2 = 1
l = list()
while c < n - 1:
	if ln2[c] + d < ln2[c2] - d:
		count += 1
	if ln2[c2] - d > ln2[c] + d:
		count += 1
	if ln2[c] + d == ln2[c2] - d:
		count += 1
	c += 1
	c2 += 1
print(count)


(n, m) = map(int, input().split())
a = [int(y) for y in input().split()]
d = 2
for i in range(1, n):
	x = a[i] - a[i - 1]
	if x == 2 * m:
		d += 1
	if x > 2 * m:
		d += 2
print(d)


(n, d) = (int(x) for x in input().split())
hotels = sorted([int(x) for x in input().split()])
hotels = [-10 ** 10] + hotels + [10 ** 10]
cities = set()
for hotel_idx in range(1, n + 1):
	if hotels[hotel_idx] - hotels[hotel_idx - 1] >= 2 * d:
		cities.add(hotels[hotel_idx] - d)
	if hotels[hotel_idx + 1] - hotels[hotel_idx] >= 2 * d:
		cities.add(hotels[hotel_idx] + d)
print(len(cities))


(n, d) = map(int, input().split())
b = [int(x) for x in input().split()]
ans = 2
for i in range(1, n):
	if b[i] - b[i - 1] == 2 * d:
		ans += 1
	elif b[i] - b[i - 1] > 2 * d:
		ans += 2
print(ans)


import math
(x, k) = map(int, input().split())
v = [int(i) for i in input().split()]
ma = 0
for i in range(x - 1):
	if v[i + 1] - v[i] == k * 2:
		ma += 1
	elif v[i + 1] - v[i] > k * 2:
		ma += 2
print(ma + 2)


(n, d) = [int(x) for x in input().split()]
ns = [int(x) for x in input().split()]
r = 2
for (idx, x) in enumerate(ns):
	if idx == 0:
		if n > 1 and x + 2 * d <= ns[idx + 1]:
			r += 1
	elif idx == n - 1:
		if n > 1 and x - 2 * d > ns[idx - 1]:
			r += 1
	else:
		if x + 2 * d <= ns[idx + 1]:
			r += 1
		if idx > 0 and x - 2 * d > ns[idx - 1]:
			r += 1
print(r)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
if n == 1:
	print(2)
else:
	ans = 2
	for i in range(n - 1):
		diff = l[i + 1] - l[i]
		if diff > 2 * d:
			ans += 2
		elif diff == 2 * d:
			ans += 1
	print(ans)


(n, d) = map(int, input().split())
data = list(map(int, input().split()))
pos = set([x - d for x in data] + [x + d for x in data])
isValid = lambda x: min((abs(x - p) for p in data)) == d
ans = len(list(filter(isValid, list(pos))))
print(ans)


(n, d) = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
t = 2
for i in range(1, n):
	if s[i] - s[i - 1] >= 2 * d:
		if s[i] - s[i - 1] == 2 * d:
			t += 1
		else:
			t += 2
print(t)


import sys

def check(a, d, v):
	min_dist = 400000000000
	for i in a:
		min_dist = min(min_dist, abs(i - v))
	if min_dist == d:
		return True
	return False
(n, d) = (int(x) for x in sys.stdin.readline().split())
a = [int(x) for x in sys.stdin.readline().split()]
ans = set()
for v in a:
	if check(a, d, v - d):
		ans.add(v - d)
	if check(a, d, v + d):
		ans.add(v + d)
print(len(ans))


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
if n == 1:
	print(2)
else:
	s = []
	count = 1
	a = l[0] + d
	if l[1] - a >= d:
		count += 1
		s.append(a)
	if n > 2:
		for i in range(1, n - 1):
			a = l[i] - d
			if a - l[i - 1] >= d and a not in s:
				count += 1
				s.append(a)
			b = l[i] + d
			if l[i + 1] - b >= d and b not in s:
				count += 1
				s.append(b)
	a = l[n - 1] - d
	if a - l[n - 2] >= d and a not in s:
		count += 1
	print(count + 1)


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a = sorted(a)
k = [a[0] - m, a[-1] + m]
for i in range(1, n):
	if a[i - 1] + m < a[i] - m:
		k.append(a[i - 1] + m)
		k.append(a[i] - m)
	elif a[i - 1] + m == a[i] - m:
		k.append(a[i] - m)
print(len(set(k)))


(n, d) = map(int, input().split(' '))
arr = input().split(' ')
for i in range(n):
	arr[i] = int(arr[i]) + 1
arr.sort()
count = 2
for i in range(n):
	if arr[i] - arr[i - 1] < 2 * d:
		continue
	if arr[i] - arr[i - 1] == 2 * d:
		count += 1
		continue
	count += 2
print(count)


(n, d) = map(int, input().split(' '))
L = [int(x) for x in input().split()]
r = set([x + d for x in L]) | set([x - d for x in L])
ans = []
for x in r:
	if min((abs(x - y) for y in L)) == d:
		ans.append(x)
print(len(ans))


(n, d) = map(int, input().split())
u = 0
l = sorted(list(map(int, input().split())))
for i in range(n - 1):
	k = l[i + 1] - l[i]
	if k % 2 == 0 and k // 2 == d:
		u = u + 1
	elif k / 2 > d:
		u = u + 2
print(u + 2)


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))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

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

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

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 lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

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

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

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

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

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
(n, d) = nninp()
a = llinp()
if n == 1:
	p(2)
else:
	s = set()
	for i in range(0, n):
		if i == 0:
			if a[i + 1] - (a[i] + d) >= d:
				s.add(a[i] + d)
		elif i == n - 1:
			if a[i] - d - a[i - 1] >= d:
				s.add(a[i] - d)
		else:
			if a[i + 1] - (a[i] + d) >= d:
				s.add(a[i] + d)
			if a[i] - d - a[i - 1] >= d:
				s.add(a[i] - d)
	p(len(s) + 2)


(n, b) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
o = 2
for i in range(n - 1):
	if a[i + 1] - a[i] == b * 2:
		o = o + 1
	elif a[i + 1] - a[i] > b * 2:
		o = o + 2
print(o)


def solve():
	(n, d) = map(int, input().strip().split())
	hotels = list(map(int, input().strip().split()))
	ans = 0
	for i in range(n - 1):
		if hotels[i + 1] - hotels[i] > 2 * d:
			ans += 2
		elif hotels[i + 1] - hotels[i] == 2 * d:
			ans += 1
	print(ans + 2)
solve()


(n, k) = map(int, input().split())
v = [int(i) for i in input().split()]
res = 2
for i in range(1, n):
	if (v[i] - v[i - 1]) / 2 > k:
		res += 2
	elif (v[i] - v[i - 1]) / 2 == k:
		res += 1
print(res)


(total, diff) = [int(x) for x in input().split(' ')]
hotel = [int(x) for x in input().split(' ')]
out = 1
past = hotel[0]
for x in range(1, total):
	curr = hotel[x]
	d = curr - past - 2 * diff + 1
	past = curr
	if d > 0 and d <= 2:
		out += d
	elif d > 2:
		out += 2
print(out + 1)


(n, d) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

def min_dist(x):
	md = None
	for c in a:
		if md is None or abs(c - x) < md:
			md = abs(c - x)
	return md
answers = set()
for x in a:
	if min_dist(x - d) == d:
		answers.add(x - d)
	if min_dist(x + d) == d:
		answers.add(x + d)
print(len(answers))


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
f = []
count = 0
for i in range(0, n - 1):
	f.append(l[i + 1] - l[i])
	if f[i] > 2 * d:
		count += 2
	elif f[i] == 2 * d:
		count += 1
count += 2
print(count)


s = input().split()
n = int(s[0])
d = int(s[1])
t = input().split()
ans = 0
ans = ans + 2
l = len(t)
for i in range(l):
	t[i] = int(t[i])
q = 0
d2 = 2 * d
for i in range(1, l):
	q = t[i] - t[i - 1]
	if q > d2:
		ans += 2
	elif q == d2:
		ans += 1
print(ans)


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
E = 2
for i in range(n - 1):
	if x[i + 1] - x[i] > 2 * d:
		E += 2
	elif x[i + 1] - x[i] == 2 * d:
		E += 1
print(E)


(n, d) = map(int, input().strip().split())
city = list(map(int, input().strip().split()))
count = 2
for i in range(1, n):
	if city[i] - city[i - 1] == 2 * d:
		count = count + 1
	elif city[i] - city[i - 1] > 2 * d:
		count = count + 2
	else:
		continue
print(count)


(n, d) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
arr_diff = [arr[i + 1] - arr[i] for i in range(len(arr) - 1)]
count = 2
for diff in arr_diff:
	if diff == d * 2:
		count += 1
	elif diff > d * 2:
		count += 2
print(count)


b = list(map(int, input().split()))
n = b[0]
d = b[1]
a = list(map(int, input().split()))
x = 2
for i in range(0, n - 1):
	c = a[i] - a[i + 1]
	c = abs(c)
	if c > 2 * d:
		x = x + 2
	elif c == 2 * d:
		x = x + 1
	else:
		continue
print(x)


(n, d) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
a = [-10 ** 10] + a + [10 ** 10]
ans = 0
for i in range(1, n + 1):
	if abs(a[i] - d - a[i - 1]) >= d:
		if abs(a[i] - d - a[i - 1]) != d:
			ans += 1
	if abs(a[i] + d - a[i + 1]) >= d:
		ans += 1
print(ans)


(n, d) = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]
p = []
for i in range(n):
	p.append([x[i] - d, x[i] + d])
ans = 2
for i in range(n - 1):
	if p[i][1] == p[i + 1][0]:
		ans += 1
	elif p[i][1] < p[i + 1][0]:
		ans += 2
print(ans)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in a:
	if i - d not in a:
		l.append(i - d)
	if i + d not in a:
		l.append(i + d)
ans = 0
l = list(set(l))
for i in l:
	x = 10 ** 10
	for j in a:
		x = min(x, abs(i - j))
	if x == d:
		ans += 1
print(ans)


s = input().split()
(n, d) = (int(s[0]), int(s[1]))
l = list(map(int, input().split()))
ls = set()
if n >= 2:
	ls.add(l[0] - d)
	if l[0] + d <= l[1] - d:
		ls.add(l[0] + d)
	for i in range(1, n - 1):
		if l[i] - d >= l[i - 1] + d:
			ls.add(l[i] - d)
		if l[i] + d <= l[i + 1] - d:
			ls.add(l[i] + d)
	if l[n - 1] - d >= l[n - 2] + d:
		ls.add(l[n - 1] - d)
	ls.add(l[n - 1] + d)
else:
	ls.add(l[0] - d)
	ls.add(l[0] + d)
print(len(ls))


(q, w) = map(int, input().split())
e = list(map(int, input().split()))
d = 0
for i in range(len(e) - 1):
	if e[i + 1] - e[i] > w * 2:
		d += 2
	elif e[i + 1] - e[i] == w * 2:
		d += 1
print(d + 2)


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
s = set()
c = 2
for i in range(0, n - 1):
	if x[i + 1] - x[i] > 2 * d:
		c += 2
	elif x[i + 1] - x[i] == 2 * d:
		c += 1
print(c)


(n, d) = [int(i) for i in input().split()]
list1 = [int(i) for i in input().split()]
total = []
count = 2
for i in range(n - 1):
	if list1[i + 1] - list1[i] == 2 * d:
		count += 1
	elif list1[i + 1] - list1[i] > 2 * d:
		count += 2
print(count)


(n, m) = map(int, input().split())
mat = list(map(int, input().split()))
res = 2
for i in range(n - 1):
	step = mat[i + 1] - mat[i]
	if step == m * 2:
		res += 1
	elif step > m * 2:
		res += 2
print(res)


R = lambda : map(int, input().split())
(n, d) = R()
arr = list(R())
ans = 2
for i in range(n - 1):
	if arr[i] + d < arr[i + 1] - d:
		ans += 2
	if arr[i] + d == arr[i + 1] - d:
		ans += 1
print(ans)


x = input()
x = x.split(' ')
n = int(x[0])
d = int(x[1])
a = input()
a = [int(i) for i in a.split()]
cnt = 0
d += d
for i in range(1, n):
	ans = abs(a[i - 1] - a[i])
	if ans == d:
		cnt += 1
	elif ans > d:
		cnt += 2
print(cnt + 2)


(n, d) = map(int, input().split())
(*a,) = map(int, input().split())
counter = 2
for i in range(n - 1):
	if a[i + 1] - a[i] > 2 * d:
		counter += 2
	elif a[i + 1] - a[i] == 2 * d:
		counter += 1
print(counter)


(n, d) = input().split()
(n, d) = [int(n), int(d)]
a = [int(i) for i in input().split()]
c = 0
b = []
for i in range(0, n):
	m1 = a[i] + d
	m2 = a[i] - d
	flag1 = 0
	flag2 = 0
	j = 0
	while j < n:
		l1 = abs(a[j] - m1)
		l2 = abs(a[j] - m2)
		if l1 < d:
			flag1 = 1
		if l2 < d:
			flag2 = 1
		j += 1
	if flag1 == 0 and flag2 == 0:
		b.append(a[i] + d)
		b.append(a[i] - d)
		c += 2
	elif flag1 == 0:
		c += 1
		b.append(a[i] + d)
	elif flag2 == 0:
		c += 1
		b.append(a[i] - d)
print(len(set(b)))


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
hotels = 2
if n == 1:
	print(hotels)
else:
	for i in range(n - 1):
		dis = (a[i + 1] - a[i]) // 2
		if dis >= d:
			l = a[i] + d
			r = a[i + 1] - d
			if l == r:
				hotels += 1
			else:
				hotels += 2
	print(hotels)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = 2
if n == 1:
	print(2)
else:
	for i in range(n):
		if i == 0:
			if l[i + 1] - l[i] > 2 * m:
				c = c + 1
		elif i < n - 1:
			if l[i] - l[i - 1] > 2 * m:
				c = c + 1
			if l[i + 1] - l[i] > 2 * m:
				c = c + 1
			if l[i] - l[i - 1] == 2 * m:
				c = c + 1
		elif i == n - 1:
			if l[i] - l[i - 1] >= 2 * m:
				c = c + 1
	print(c)


(n, d) = map(int, input().split())
cities = list(map(int, input().split()))
counter = 2
for i in range(1, n):
	if cities[i] - cities[i - 1] > 2 * d:
		counter += 2
	elif cities[i] - cities[i - 1] == 2 * d:
		counter += 1
print(counter)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
count = 2
for i in range(1, n):
	if abs(l[i - 1] - l[i]) > 2 * d:
		count += 2
	elif abs(l[i] - l[i - 1]) == 2 * d:
		count += 1
	else:
		pass
print(count)


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
z = 2
for i in range(len(l) - 1):
	if l[i + 1] - l[i] > 2 * b:
		z += 2
	elif l[i + 1] - l[i] == 2 * b:
		z += 1
	else:
		pass
print(z)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
h = 0
for i in range(len(l) - 1):
	if abs(l[i] - l[i + 1]) > 2 * d:
		h += 2
	elif abs(l[i] - l[i + 1]) == 2 * d:
		h += 1
print(h + 2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
t = 2
for i in range(n - 1):
	j = i + 1
	if a[i] + k <= a[j] - k:
		t += 1
	if a[j] - k > a[i] + k:
		t += 1
print(t)


(n, d) = input().split()
(n, d) = (int(n), int(d))
li1 = list(map(int, input().split()))
leg = len(li1)
coun = 2
for i in range(leg - 1):
	a = abs(li1[i] - li1[i + 1]) - 1 - (d - 1) * 2
	if a > 0 and a < 2:
		coun += 1
	elif a > 0 and a >= 2:
		coun += 2
print(coun)


(n, d) = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
h.sort()
ha = 0
lc = []
while ha != len(h):
	if ha == 0:
		lc += [h[ha] - d]
	if ha > 0:
		if h[ha] - d > h[ha - 1] + d:
			lc += [h[ha] - d]
	if ha + 1 < len(h):
		if h[ha] + d <= h[ha + 1] - d:
			lc += [h[ha] + d]
	if ha == len(h) - 1:
		lc += [h[ha] + d]
	ha += 1
print(len(lc))


import bisect
(n, d) = map(int, input().split())
a = [-10 ** 10] + list(map(int, input().split())) + [10 ** 10]
b = list()
ans = 0
for i in range(1, n + 1):
	x = a[i]
	if x - d not in a and x - d not in b and (a[i - 1] <= x - 2 * d):
		b.append(x - d)
		ans += 1
	if x + d not in a and x + d not in b and (a[i + 1] >= x + 2 * d):
		b.append(x + d)
		ans += 1
print(ans)


(n, d) = map(int, input().split())
x = sorted(list(map(int, input().split())))
res = 2
for i in range(len(x) - 1):
	(a, b) = (x[i], x[i + 1])
	if b - a >= 2 * d:
		res += 1
	if b - a > 2 * d:
		res += 1
print(res)


(n, k) = list(map(int, input().split()))
d = list(map(int, input().split()))
result = 2
for i in range(len(d) - 1):
	if d[i + 1] - d[i] == k * 2:
		result += 1
	elif d[i + 1] - d[i] > k * 2:
		result += 2
print(result)


from operator import itemgetter
(n, d) = map(int, input().split())
xi = list(map(int, input().split()))
ans = 2
num = xi[0] + d
if n > 1 and min(abs(num - xi[0]), abs(num - xi[1])) == d:
	ans += 1
if num != xi[-1] - d:
	num = xi[-1] - d
	if n > 1 and min(abs(num - xi[-2]), abs(num - xi[-1])) == d:
		ans += 1
num = xi[0] + d
for i in range(1, n - 1):
	if num != xi[i] - d:
		num = xi[i] - d
		if min(abs(num - xi[i - 1]), abs(num - xi[i])) == d:
			ans += 1
	num = xi[i] + d
	if min(abs(num - xi[i + 1]), abs(num - xi[i])) == d:
		ans += 1
if n > 2 and xi[-1] - d == xi[-2] + d:
	ans -= 1
print(ans)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
pre = a[0]
num = 0
for i in range(1, n):
	if abs(a[i] - pre) == 2 * d:
		num += 1
	elif abs(a[i] - pre) > 2 * d:
		num += 2
	pre = a[i]
print(num + 2)


nd = [int(x) for x in input().split()]
list = [int(x) for x in input().split()]
n = nd[0]
d = nd[1]
initialSize = n
min = 2
i = 0
for i in range(n - 1):
	if list[i + 1] - list[i] - 2 * d > 0:
		min += 2
	elif list[i + 1] - list[i] - 2 * d == 0:
		min += 1
print(min)


[n, d] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
c = 2
for i in range(len(A) - 1):
	temp = A[i + 1] - A[i]
	if temp == 2 * d:
		c += 1
	elif temp > 2 * d:
		c += 2
print(c)


import sys
import math

def scan(input_type='int'):
	if input_type == 'int':
		return list(map(int, sys.stdin.readline().strip().split()))
	else:
		return list(map(str, sys.stdin.readline().strip()))

def solution():
	(n, d) = scan()
	a = scan()
	c = 0
	for i in range(n - 1):
		e = abs(a[i] - a[i + 1])
		if e > 2 * d:
			c += 2
		elif e == 2 * d:
			c += 1
	print(c + 2)
solution()


import sys
import math
(n, d) = map(int, input().split())
if d % 2 == 0:
	a = 2 * d
	b = 2 * d + 1
else:
	a = 2 * d
	b = 2 * d - 1
lista = [int(x) for x in input().strip().split()]
dista = [0 for i in range(n - 1)]
cnt = 2
for i in range(1, n):
	dista[i - 1] = lista[i] - lista[i - 1]
	if dista[i - 1] >= 2 * d + 1:
		cnt += 2
	elif dista[i - 1] == 2 * d:
		cnt += 1
print(cnt)


(n, d) = [*map(int, input().split())]
lo = [*map(int, input().split())]
lo = sorted(lo)
ans = 2
lo1 = []
for i in range(n - 1):
	lo1.append(lo[i + 1] - lo[i])
for i in lo1:
	if i > 2 * d:
		ans += 2
	elif i >= 2 * d:
		ans += 1
	else:
		pass
print(ans)


(n, d) = map(int, input().split())
a = [int(x) for x in input().split()]
test = set()
for x in a:
	fi = x + d
	se = x - d
	if min((abs(coord - fi) for coord in a)) == d:
		test.add(fi)
	if min((abs(coord - se) for coord in a)) == d:
		test.add(se)
print(len(test))


(n, k) = map(int, input().split())
ans = []
a = list(map(int, input().split()))
for i in range(1, n - 1):
	if a[i] - a[i - 1] >= 2 * k:
		ans.append(a[i] - k)
	else:
		pass
	if a[i + 1] - a[i] >= 2 * k:
		ans.append(a[i] + k)
	else:
		pass
if len(a) > 1:
	if a[0] + 2 * k <= a[1]:
		ans.append(a[0] + k)
	else:
		pass
	if a[-1] - 2 * k >= a[-2]:
		ans.append(a[-1] - k)
	else:
		pass
else:
	pass
ans.append(a[0] - k)
ans.append(a[-1] + k)
ans = set(ans)
ans = list(ans)
print(len(ans))


(n, d) = input().split()
n = int(n)
d = int(d)
arr = [int(x) for x in input().split()]
count = 2
used = []
for i in range(0, n - 1):
	distance = arr[i + 1] - arr[i]
	if distance > 2 * d:
		count += 2
	elif distance == 2 * d:
		count += 1
print(count)


(n, d) = list(map(int, input().split()))
X = list(map(int, input().split()))
count = 2
dd = 2 * d
for i in range(n - 1):
	if X[i + 1] - X[i] == dd:
		count += 1
	if X[i + 1] - X[i] > dd:
		count += 2
print(count)


(n, d) = map(int, input().split())
hotels = list(map(int, input().strip().split()))
curr = 0
prev = hotels[0]
res = 2
for i in range(1, n):
	curr = hotels[i]
	diff = curr - prev
	dist = 2 * d
	if diff == dist:
		res += 1
	elif diff > dist:
		res += 2
	else:
		pass
	prev = curr
print(res)


def mn(x):
	ans = abs(ar[0] - x)
	for el in ar:
		ans = min(ans, abs(x - el))
	return ans
(n, d) = map(int, input().split())
ar = sorted(list(map(int, input().split())))
s = set()
for x in ar:
	s.add(x + d)
	s.add(x - d)
ans = 0
for x in s:
	if mn(x) == d:
		ans += 1
print(ans)


lis = []

def forw(li, n, m):
	che = 0
	for i in range(0, n - 1):
		if li[i] + m <= li[i + 1] - m:
			lis.append(li[i] + m)

def back(li, n, m):
	chi = 0
	for i in range(1, n):
		if li[-i] - m >= li[-i - 1] + m:
			lis.append(li[-i] - m)
(n, m) = map(int, input().split())
li = list(map(int, input().split()))
forw(li, n, m)
back(li, n, m)
print(len(set(lis)) + 2)


list0 = [int(a) for a in input('').split()]
n = list0[0]
d = list0[1]
D = input('')
num = 2
list1 = [int(b) for b in D.split()]
for i in range(0, n - 1):
	if list1[i + 1] - list1[i] == d * 2:
		num += 1
	elif list1[i + 1] - list1[i] > d * 2:
		num += 2
print(num)


import sys
(n, d) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
res = 2
for i in range(len(x)):
	if i > 0 and abs(x[i] - d - x[i - 1]) >= d:
		res += 1
	if i < len(x) - 1 and abs(x[i] + d - x[i + 1]) > d:
		res += 1
print(res)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	(n, d) = LI()
	a = sorted(LI())
	r = 2
	for i in range(n - 1):
		t = a[i + 1] - a[i]
		if t > d * 2:
			r += 2
		elif t == d * 2:
			r += 1
	return r
print(main())


(n, d) = list(map(int, input().split()))
s = list(map(int, input().split()))
t = 2
for i in range(n - 1):
	if s[i + 1] - s[i] == 2 * d:
		t += 1
	if s[i + 1] - s[i] > 2 * d:
		t += 2
print(t)


c = 2
(n, k) = map(int, input().split())
li = list(map(int, input().split()))
for i in range(n - 1):
	if abs(li[i] - li[i + 1]) > 2 * k:
		c += 2
	elif abs(li[i] - li[i + 1]) == 2 * k:
		c += 1
print(c)


(n, d) = map(int, input().split())
arr = list(map(int, input().split()))
rez = 2
for i in range(n - 1):
	rez += min(2, max(0, arr[i + 1] - arr[i] - d * 2 + 1))
print(rez)


(n, d) = [int(i) for i in input().split()]
x = sorted([int(i) for i in input().split()])
possible = set([i - d for i in x] + [i + d for i in x])
total = 0
for i in possible:
	if min([abs(i - j) for j in x]) == d:
		total += 1
print(f'{total}\n')


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
ans = 2
for i in range(n - 1):
	if arr[i + 1] - arr[i] > 2 * k:
		ans += 2
	elif arr[i + 1] - arr[i] == 2 * k:
		ans += 1
print(ans)


from sys import stdin, stdout
from collections import deque
(n, d) = map(int, stdin.readline().split())
values = list(map(int, stdin.readline().split()))
ans = set()
for i in range(n):
	cur = values[i] - d
	mn = 10 ** 10
	for j in range(n):
		if abs(cur - values[j]) < mn:
			mn = abs(cur - values[j])
	if mn == d:
		ans.add(cur)
	cur = values[i] + d
	mn = 10 ** 10
	for j in range(n):
		if abs(cur - values[j]) < mn:
			mn = abs(cur - values[j])
	if mn == d:
		ans.add(cur)
stdout.write(str(len(ans)))


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
k = set()
for i in range(n):
	if i == 0:
		k.add(l[i] - d)
		first = l[i] + d
		try:
			if l[i + 1] - d >= first:
				k.add(l[i] + d)
			continue
		except:
			k.add(l[i] + d)
			continue
	if i == n - 1:
		k.add(l[i] + d)
		first = l[i] - d
		if l[i - 1] + d <= first:
			k.add(l[i] - d)
		continue
	first = l[i] - d
	if l[i - 1] + d <= first:
		k.add(l[i] - d)
	second = l[i] + d
	if l[i + 1] - d >= second:
		k.add(l[i] + d)
print(len(k))


import sys
in_1 = input().split(' ')
arr = [-sys.maxsize * sys.maxsize] + [int(i) for i in input().split(' ')] + [sys.maxsize * sys.maxsize]
n = int(in_1[0])
m = int(in_1[1])
ans = 0
for i in range(1, n + 1):
	if arr[i - 1] + m < arr[i] - m:
		ans += 1
	if arr[i + 1] - m > arr[i] + m:
		ans += 1
	if arr[i + 1] - m == arr[i] + m:
		ans += 1
print(int(ans))


import sys
n = input().split()
number_of_hotels = int(n[0])
distance = int(n[1])
hotel_coordinates = [int(x) for x in input().split()]
hotel_coordinates_length = len(hotel_coordinates)
sorted(hotel_coordinates)
possible_cities = 2
i = 0
for i in range(hotel_coordinates_length - 1):
	if abs(hotel_coordinates[i] - hotel_coordinates[i + 1]) == 2 * distance:
		possible_cities += 1
	elif abs(hotel_coordinates[i] - hotel_coordinates[i + 1]) > 2 * distance:
		possible_cities += 2
print(possible_cities)


(n, d) = map(int, input().split())
ans = []
x = list(map(int, input().split()))
for xi in x:
	ans.append(xi - d)
	ans.append(xi + d)
real_ans = []
for a in set(ans):
	if not any((abs(xi - a) < d for xi in x)):
		real_ans.append(a)
print(len(real_ans))


(n, d) = map(int, input().split())
ls = list(map(int, input().split()))
c = 2
if n == 1:
	print(2)
else:
	for i in range(1, len(ls)):
		if abs(ls[i] - ls[i - 1]) == d * 2:
			c += 1
		elif abs(ls[i] - ls[i - 1]) > d * 2:
			c += 2
		else:
			continue
	print(c)


import sys
(n, d) = map(int, input().split())
if n == 1:
	print(2)
	sys.exit()
lst = list(map(int, input().split()))
lst.append(lst[-1] + 2 * d)
pts = {lst[0] - d}
if lst[0] + d <= lst[1] - d:
	pts.add(lst[0] + d)
for i in range(1, n):
	if lst[i] + d <= lst[i + 1] - d:
		pts.add(lst[i] + d)
	if lst[i] - d >= lst[i - 1] + d:
		pts.add(lst[i] - d)
print(len(pts))


import math
(n, d) = map(int, input().split())
p = list(map(int, input().split()))
q = []
for i in range(len(p) - 1):
	q.append(abs(p[i + 1] - p[i]))
count = 0
for k in q:
	if k == 2 * d:
		count += 1
	elif k >= 2 * d:
		count += 2
print(count + 2)


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
b = []
c = []
e = []
for i in x:
	b.append(i - d)
	b.append(i + d)
	c.append(b)
	b = []
y = [x for bb in c for x in bb]
z = sorted(y)
for i in range(0, len(z)):
	if y[i] == z[i]:
		e.append(y[i])
v = set(e)
print(len(v))


(n, k) = map(int, input().split())
k *= 2
l = input().split()
sumi = 2
for x in range(len(l) - 1):
	y = int(l[x + 1]) - int(l[x])
	if y == k:
		sumi += 1
	elif y > k:
		sumi += 2
print(sumi)


a = [int(q) for q in input().strip().split()]
b = [int(q) for q in input().strip().split()]
ct = 2
for k in range(len(b) - 1):
	if b[k + 1] - b[k] == 2 * a[1]:
		ct += 1
	elif b[k + 1] - b[k] > 2 * a[1]:
		ct += 2
print(ct)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
co = 2
for i in range(n - 1):
	p = l[i + 1] - l[i]
	if p > d * 2:
		co += 2
	elif p == d * 2:
		co += 1
print(co)


a = input()
b = a.split()
n = int(b[0])
dd = int(b[1])
c = input()
d = c.split()
for i in range(n):
	d[i] = int(d[i])
c = 2
for j in range(1, n):
	if d[j] - d[j - 1] > 2 * dd:
		c += 2
	elif d[j] - d[j - 1] == 2 * dd:
		c += 1
print(c)


(n, d) = map(int, input().split(' '))
a = input().split(' ')
for i in range(n):
	a[i] = int(a[i])
a.insert(0, a[0] - 2 * d)
a.append(a[n] + 2 * d)
count = 0
for i in range(1, n + 2):
	if a[i] - a[i - 1] == 2 * d:
		count += 1
	elif a[i] - a[i - 1] > 2 * d:
		count += 2
print(count)


count = set()
ND = input().split()
(n, d) = (int(ND[0]), int(ND[1]))
H = input().split()
for j in range(n):
	xm = int(H[j]) - d
	xp = int(H[j]) + d
	minm = 1000000001
	minp = 1000000001
	for k in range(n):
		if minm > abs(int(H[k]) - xm):
			minm = abs(int(H[k]) - xm)
		if minp > abs(int(H[k]) - xp):
			minp = abs(int(H[k]) - xp)
	if minm == d:
		count.add(xm)
	if minp == d:
		count.add(xp)
print(len(count))


c = input()
c = c.split(' ')
n = int(c[0])
d = int(c[1])
a = input()
a = a.split(' ')
i = 0
se = set()
while i < n:
	se.add(int(a[i]) - d)
	se.add(int(a[i]) + d)
	i += 1
ans = 0
for x in se:
	no = 0
	for j in a:
		if abs(int(j) - int(x)) < d:
			no = 1
	if no == 0:
		ans += 1
print(ans)


(n, d) = map(int, input().split())
X = [int(i) for i in input().split()]
X.sort()
hotel_number = 2
cnt = 0
for i in range(1, len(X)):
	if X[i] - X[i - 1] > 2 * d:
		hotel_number += 2
	elif X[i] - X[i - 1] == 2 * d:
		hotel_number += 1
print(hotel_number)


from sys import stdin
from collections import defaultdict
(n, d) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
res = set()
for i in range(n):
	l = c[i] - d
	r = c[i] + d
	if i == 0 or abs(c[i - 1] - l) >= d:
		res.add(l)
	if i == n - 1 or abs(c[i + 1] - r) >= d:
		res.add(r)
print(len(res))


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
	b.append(i)
	if i + d not in b and i + d not in a:
		b.append(i + d)
	if i - d not in b and i - d not in a:
		b.append(i - d)
b.sort()
for i in range(n):
	val = b[b.index(a[i])]
	z = b[b.index(a[i]) - 1]
	while abs(val - z) != d and z not in a:
		b.remove(z)
		z = b[b.index(a[i]) - 1]
	z = b[b.index(a[i]) + 1]
	while abs(z - val) != d and z not in a:
		b.remove(z)
		z = b[b.index(a[i]) + 1]
print(len(b) - len(a))


(n, d) = map(int, input().split())
s = [int(elem) for elem in input().split()]
s = [-10 ** 9] + s
s.append(10 ** 9)
ans = 0
for i in range(1, n):
	if s[i + 1] - s[i] == 2 * d:
		ans = ans + 1
	elif s[i + 1] - s[i] > 2 * d:
		ans = ans + 2
print(ans + 2)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	(n, d) = lst()
	a = sorted(lst())
	s = set()
	for i in range(n):
		x = a[i] - d
		left = a[i - 1] if i >= 1 else float('inf')
		if abs(x - left) >= d:
			s.add(x)
		x = a[i] + d
		right = a[i + 1] if i + 1 < n else float('inf')
		if abs(x - right) >= d:
			s.add(x)
	print(len(s))


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
count = 2
z = [l[0] - d, l[-1] + d]
for i in range(1, n):
	if l[i - 1] + d <= l[i] - d:
		z.append(l[i - 1] + d)
		z.append(l[i] - d)
print(len(set(z)))


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
d1 = [a[i + 1] - a[i] for i in range(n - 1) if a[i + 1] - a[i] >= 2 * x]
d1 = 2 + sum([1 if di == 2 * x else 2 for di in d1])
print(d1)


class CodeforcesTask1004ASolution:

	def __init__(self):
		self.result = ''
		self.n_d = []
		self.locations = []

	def read_input(self):
		self.n_d = [int(x) for x in input().split(' ')]
		self.locations = [int(x) for x in input().split(' ')]

	def process_task(self):
		positions = 2
		locked = []
		for x in range(self.n_d[0] - 1):
			locked.append(self.locations[x + 1] - self.locations[x])
		unlocked = [x for x in locked if x >= self.n_d[1] * 2]
		positions += sum([1 if x == self.n_d[1] * 2 else 2 for x in unlocked])
		self.result = str(positions)

	def get_result(self):
		return self.result
Solution = CodeforcesTask1004ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


d = int(input().split()[1])
h = input().split()
for i in range(len(h)):
	h[i] = int(h[i])
wy = 2
for i in range(len(h) - 1):
	if h[i + 1] - h[i] == d * 2:
		wy += 1
	elif h[i + 1] - h[i] > d * 2:
		wy += 2
print(wy)


(a, b) = input().split()
a = int(a)
b = int(b)
c = input().split()
c = list(map(int, c))
d = {}
d[c[0] - b] = 0
k = []
for i in range(a - 1):
	if c[i + 1] - (c[i] + b) >= b:
		d[c[i] + b] = 0
	if c[i + 1] - b - c[i] >= b:
		d[c[i + 1] - b] = 0
d[c[a - 1]] = 0
print(len(d.keys()))


(n, d) = map(int, input().split())
koord = list(map(int, input().split()))
ans = 2
sums = []
for i in range(1, n):
	sums.append(koord[i] - koord[i - 1])
for i in sums:
	if i > 2 * d:
		ans += 2
	elif i == 2 * d:
		ans += 1
print(ans)


(n, d) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = 2
temp = 0
for i in range(n):
	k = a[i] + d
	j = a[i] - d
	if i != n - 1 and a[i + 1] - k >= d:
		ans += 1
	if i != 0 and j - a[i - 1] >= d and (j != temp):
		ans += 1
	temp = k
print(ans)


(a, b) = map(int, input().split())
l = [int(x) for x in input().split()]
c = 2
for i in range(1, a):
	k = l[i] - b
	if k - l[i - 1] >= b:
		c += 1
for i in range(0, a - 1):
	k = l[i] + b
	if l[i + 1] - k > b:
		c += 1
print(c)


(n, d) = map(int, input().split())
l = list(map(int, input().split()))
(count, d) = (2, 2 * d)
for i in range(n - 1):
	count += 2 * (l[i + 1] - l[i] > d) + (l[i + 1] - l[i] == d)
print(count)


def main():
	(n, d) = map(int, input().split())
	aa = sorted(map(int, input().split()))
	(res, i) = (set(), 0)
	for x in aa[1:]:
		while aa[i] < x:
			i += 1
		if min(x - d - aa[i - 1], aa[i] - x + d) == d:
			res.add(x - d)
	i = n - 1
	for x in aa[-2::-1]:
		while aa[i] > x:
			i -= 1
		if min(x + d - aa[i], aa[i + 1] - x - d) == d:
			res.add(x + d)
	print(len(res) + 2)
main()


(n, d) = map(int, input().split())
l = [*map(int, input().split())]
ans = 2
tmp = {}
for i in range(n):
	if i + 1 != n and l[i + 1] - (l[i] + d) >= d and (tmp.get(l[i] + d, -1) == -1):
		ans += 1
		tmp[l[i] + d] = 1
	if i - 1 != -1 and l[i] - d - l[i - 1] >= d and (tmp.get(l[i] - d, -1) == -1):
		ans += 1
		tmp[l[i] - d] = 1
print(ans)


(n, d) = map(int, input().strip().split())
x = list(map(int, input().strip().split()))
count = 2
for i in range(n - 1):
	diff = x[i + 1] - x[i]
	if diff > 2 * d:
		count = count + 2
	elif diff == 2 * d:
		count = count + 1
print(count)


import sys
(n, d) = map(int, sys.stdin.readline().split())
l = list(map(int, input().strip().split(' ')))
count = 0
i = 1
for j in range(n - 1):
	val = l[i] - l[i - 1]
	if val >= 2 * d:
		count += 1
		if val > 2 * d:
			count += 1
	else:
		pass
	i += 1
count += 2
print(count)


a = list(map(int, input().split()))
t = a[0]
d = a[1]
arr = list(map(int, input().split()))
count = 0
for i in range(t - 1):
	if arr[i + 1] - arr[i] == 2 * d:
		count += 1
	elif arr[i + 1] - arr[i] > 2 * d:
		count += 2
print(count + 2)


def forbiddenrange(range, x):
	for (a, b) in range:
		if x > a and x < b:
			return False
	return True
line1 = input()
line2 = input()
(n, d) = [int(x) for x in line1.split(' ')]
cities = [int(x) for x in line2.split(' ')]
range = [(x - d, x + d) for x in cities]
x = 0
newcities = {}
for a in cities:
	if forbiddenrange(range, a + d):
		if not a + d in newcities:
			newcities[a + d] = True
			x += 1
	if forbiddenrange(range, a - d):
		if not a - d in newcities:
			newcities[a - d] = True
			x += 1
print(x)


(n, d) = map(int, input().split(' '))
xs = list(map(int, input().split(' ')))
print(2 + sum((1 if b - a == 2 * d else 2 if b - a > 2 * d else 0 for (a, b) in zip(xs, xs[1:]))))


import collections
from functools import cmp_to_key
import math
import sys

def getIntList():
	return list(map(int, input().split()))
import bisect
try:
	import numpy
	dprint = print
	dprint('debug mode')
except ModuleNotFoundError:

	def dprint(*args, **kwargs):
		pass

def makePair(z):
	return [(z[i], z[i + 1]) for i in range(0, len(z), 2)]

def memo(func):
	cache = {}

	def wrap(*args):
		if args not in cache:
			cache[args] = func(*args)
		return cache[args]
	return wrap

@memo
def comb(n, k):
	if k == 0:
		return 1
	if n == k:
		return 1
	return comb(n - 1, k - 1) + comb(n - 1, k)
(n, d) = getIntList()
zx = getIntList()
res = set()
for x in zx:
	res.add(x - d)
	res.add(x + d)
tot = 0
for x in res:
	flag = True
	for y in zx:
		if abs(x - y) < d:
			flag = False
	if flag:
		tot += 1
print(tot)


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
new_cities = []
for i in range(len(x)):
	new_pos1 = x[i] + d
	new_pos2 = x[i] - d
	if len(x) == 1:
		new_cities.append(new_pos1)
		new_cities.append(new_pos2)
	if new_pos1 not in x and new_pos1 not in new_cities:
		if i != 0 and i != len(x) - 1 and (abs(new_pos1 - x[i - 1]) >= d) and (abs(new_pos1 - x[i + 1]) >= d):
			new_cities.append(new_pos1)
		elif i == 0 and abs(new_pos1 - x[i + 1]) >= d:
			new_cities.append(new_pos1)
		elif i == len(x) - 1 and abs(new_pos1 - x[i - 1]) >= d:
			new_cities.append(new_pos1)
	if new_pos2 not in x and new_pos2 not in new_cities:
		if i != 0 and i != len(x) - 1 and (abs(new_pos2 - x[i - 1]) >= d) and (abs(new_pos2 - x[i + 1]) >= d):
			new_cities.append(new_pos2)
		elif i == 0 and abs(new_pos2 - x[i + 1]) >= d:
			new_cities.append(new_pos2)
		elif i == len(x) - 1 and abs(new_pos2 - x[i - 1]) >= d:
			new_cities.append(new_pos2)
print(len(new_cities))


(n, d) = input().split(' ')
n = int(n)
d = int(d)
inp = list(map(lambda x: int(x), input().split(' ')))
count = 2
for i in range(n - 1):
	if -inp[i] + inp[i + 1] > 2 * d:
		count += 2
	elif -inp[i] + inp[i + 1] == 2 * d:
		count += 1
print(count)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
b = [a[0] - d, a[n - 1] + d]
for i in range(n - 1):
	x = a[i + 1] - d
	y = a[i] + d
	if a[i + 1] - y >= d and y not in b:
		b.append(y)
	if a[i + 1] - a[i] >= 2 * d and x not in b:
		b.append(x)
print(len(b))


def I():
	return [int(i) for i in input().split()]
(n, d) = I()
l = I()
count = 2
for i in range(n - 1):
	if l[i] + d <= l[i + 1] - d:
		count += 1
	if l[i + 1] - d > l[i] + d:
		count += 1
print(count)


(n, d) = map(int, input().split())
X = [-10 ** 10] + list(map(int, input().split())) + [10 ** 10]
ans = 0
p = 0
for i in range(1, n + 1):
	if abs(X[i - 1] - (X[i] - d)) > d:
		ans += 1
	if abs(X[i + 1] - (X[i] + d)) > d:
		ans += 1
	if abs(X[i - 1] - (X[i] - d)) == d:
		p += 1
		ans += 1
	if abs(X[i + 1] - (X[i] + d)) == d:
		p += 1
		ans += 1
p = p // 2
ans -= p
print(ans)


(n, distance) = input().split()
n = int(n)
distance = int(distance)
lst = list(map(int, input().split()))
i = 0
count = 2
while i < len(lst) - 1:
	diff = abs(lst[i] - lst[i + 1])
	if diff // 2 >= distance:
		if diff % 2 == 0:
			diff1 = diff / 2
			if diff1 == distance:
				count += 1
			else:
				count += 2
		else:
			count += 2
	i += 1
print(count)


(n, d) = map(int, input().split())
x = sorted([*map(int, input().split())])
s = {None, *x}
r = 0
for i in x:
	for j in (i + d if min(map(lambda y: abs(y - (i + d)), x)) == d else None, i - d if min(map(lambda y: abs(y - (i - d)), x)) == d else None):
		if j not in s:
			s.add(j)
			r += 1
print(r)


from math import sqrt

def solve(a, n, d):
	count = 2
	for i in range(1, n):
		v = abs(a[i] - a[i - 1])
		if v > d * 2:
			count += 2
		elif v == d * 2:
			count += 1
	return count

def main():
	vars = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	print(solve(a, *vars))
main()


(x, y) = map(int, input().split())
n = 0
p = list(map(int, input().split()))
for i in range(x - 1):
	f = abs(p[i] - p[i + 1])
	if f > y * 2:
		n += 2
	if f == y * 2:
		n += 1
print(n + 2)


import sys
import os

def sonyaAndHotels(n, d, points):
	result = 1
	first = True
	for pt in points:
		if not first:
			if pt - d == now:
				result += 1
				now = pt + d
			elif pt - d > now:
				result += 2
		now = pt + d
		first = False
	return result + 1

def main():
	(n, d) = (int(x) for x in input().split())
	points = [int(x) for x in input().split()]
	print(sonyaAndHotels(n, d, points))
main()


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
cnt = 0
for i in range(0, n):
	if i + 1 >= n:
		break
	else:
		t = x[i + 1] - x[i]
		if t < 2 * d:
			cnt += 0
		elif t == 2 * d:
			cnt += 1
		elif t > 2 * d:
			cnt += 2
print(cnt + 2)


(n, l) = map(int, input().split())
li = list(map(int, input().split()))
count = 0
for i in range(1, n):
	k = li[i] - li[i - 1]
	if k - 2 * l == 0:
		count += 1
	if k - 2 * l > 0:
		count += 2
print(count + 2)


s = input()
s = s.split(' ')
n = int(s[0])
d = int(s[1])
l = input()
l = l.split(' ')
for i in range(n):
	l[i] = int(l[i])
resu = 2
for i in range(n - 1):
	if l[i + 1] - l[i] == 2 * d:
		resu = resu + 1
	if l[i + 1] - l[i] > 2 * d:
		resu = resu + 2
print(resu)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
s.add(a[0] - d)
s.add(a[-1] + d)
for i in range(1, n):
	if a[i - 1] + d + d <= a[i]:
		s.add(a[i - 1] + d)
		s.add(a[i] - d)
print(len(s))


(n, d) = map(int, input().split())
hotels = list(map(int, input().split()))
count = 2
for i in range(0, n - 1):
	q = 0
	if int(hotels[i]) + d <= int(hotels[i + 1]) - d:
		if int(hotels[i]) + d == int(hotels[i + 1]) - d:
			count += 1
		else:
			count += 2
print(count)


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in range(n - 1):
	if a[i + 1] - a[i] > 2 * d:
		s = s + 2
	if a[i + 1] - a[i] == 2 * d:
		s = s + 1
print(s + 2)


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
count = 2
if n > 1:
	for i in range(1, n):
		temp = x[i] - x[i - 1]
		if temp == 2 * d:
			count = count + 1
		if temp > 2 * d:
			count = count + 2
print(count)


(n, d) = map(int, input().split())
hotels = list(map(int, input().split()))
answer = 2
for (i, hotel) in enumerate(hotels, 0):
	if i:
		if hotels[i] - hotels[i - 1] > 2 * d:
			answer += 2
		elif hotels[i] - hotels[i - 1] == 2 * d:
			answer += 1
print(answer)


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
c = 2
for i in range(1, n):
	if l[i] - l[i - 1] > 2 * k:
		c += 2
	elif l[i] - l[i - 1] == 2 * k:
		c += 1
print(c)


def main():
	rd = lambda : list(map(int, input().split()))
	(n, d) = rd()
	arr = rd()
	cnt = 0
	reserved = []
	if n == 1:
		print(2)
		return
	for i in range(1, n - 1):
		item = arr[i]
		est1 = item + d
		est2 = item - d
		if est2 - arr[i - 1] >= d and est2 not in reserved:
			cnt += 1
			reserved.append(est2)
		if arr[i + 1] - est1 >= d and est1 not in reserved:
			cnt += 1
			reserved.append(est1)
	cnt += 2
	est1 = arr[0] + d
	if arr[1] - est1 >= d and est1 not in reserved:
		cnt += 1
		reserved.append(est1)
	est2 = arr[n - 1] - d
	if est2 - arr[n - 2] >= d and est2 not in reserved:
		cnt += 1
		reserved.append(est2)
	print(cnt)
main()


(n, d) = [int(x) for x in input().strip().split()]
x = [int(x) for x in input().strip().split()]
d *= 2
x.sort()
ans = 2
for i in range(len(x) - 1):
	diff = x[i + 1] - x[i]
	if diff == d:
		ans += 1
	elif diff > d:
		ans += 2
print(ans)


(n, d) = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
g = 2
for i in range(n - 1):
	if t[i + 1] - t[i] > 2 * d:
		g += 2
	elif t[i + 1] - t[i] == 2 * d:
		g += 1
print(g)


(n, d) = [int(s) for s in input().split(' ')]
numbers = [int(s) for s in input().split(' ')]
answer = 2
for i in range(0, len(numbers) - 1):
	x = numbers[i + 1] - numbers[i] - 2 * d
	if x > 0:
		answer += 2
	elif x == 0:
		answer += 1
print(answer)


def main():
	[n, d] = [int(_) for _ in input().split()]
	hotels = [int(_) for _ in input().split()]
	result = 2
	for i in range(n - 1):
		left = hotels[i] + d
		right = hotels[i + 1] - d
		result += 1 if left == right else 2 if left < right else 0
	print(result)
main()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
(n, d) = get_int_list()
lst = get_int_list()
count = 2
for i in range(1, n):
	if lst[i] - lst[i - 1] == 2 * d:
		count += 1
	elif lst[i] - lst[i - 1] >= 2 * d:
		count += 2
print(count)


(n, d) = [int(x) for x in input().split()]
x = [int(w) for w in input().split()]
x.sort()
res = 1
for i in range(n):
	if i != 0 and x[i] - x[i - 1] >= 2 * d:
		if x[i] - x[i - 1] == 2 * d:
			res += 1
		else:
			res += 2
res += 1
print(res)


i = lambda : [*map(int, input().split())]
d = i()[1]
a = i()
print(len(set([x + y for y in [-d, d] for x in a if min((abs(x + y - z) for z in a)) == d])))


(n, d) = map(int, input().split())
x = list(map(int, input().split()))
print(len(set((x[i] + d for i in range(0, n - 1) if x[i + 1] - x[i] >= 2 * d)).union(set((x[i] - d for i in range(1, n) if x[i] - x[i - 1] >= 2 * d)))) + 2)


def go():
	(n, d) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	if n == 1:
		return 2
	total = 2
	for i in range(0, n - 1):
		if a[i] + d == a[i + 1] - d:
			total += 1
		elif a[i] + d < a[i + 1] - d:
			total += 2
	return total
print(go())


(n, d) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
res_set = set()
x = A[0] + d
if len(A) >= 2:
	if abs(A[1] - x) >= d:
		res_set.add(x)
for i in range(1, n - 1):
	(x1, x2) = (A[i] + d, A[i] - d)
	if abs(A[i - 1] - x2) >= d:
		res_set.add(x2)
	if abs(A[i + 1] - x1) >= d:
		res_set.add(x1)
x = A[-1] - d
if len(A) >= 2:
	if abs(A[-2] - x) >= d:
		res_set.add(x)
print(len(res_set) + 2)


rd = lambda : list(map(int, input().split()))
(n, d) = rd()
a = rd()
r = 2
for (x, y) in zip(a, a[1:]):
	p = y - x - 2 * d
	if p >= 0:
		r += 1 + (p > 0)
print(r)


d = int(input().split()[-1])
hotels = list(map(int, input().split()))

def new_hotel_location(d, hotels):
	spacing = []
	for i in range(len(hotels) - 1):
		spacing.append(hotels[i + 1] - hotels[i])
	dd = d * 2
	counting = 0
	for item in spacing:
		if item == dd:
			counting += 1
		elif item > dd:
			counting += 2
	return counting + 2
print(new_hotel_location(d, hotels))


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
a.append(10000000000)
a.insert(0, -10000000000)
ans = 0
for i in range(1, len(a)):
	l = a[i] - a[i - 1]
	if l > 2 * d:
		ans = ans + 2
	elif l == 2 * d:
		ans = ans + 1
print(ans - 2)