You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 ≤ N ≤ 200,000, 1 ≤ T ≤ 10^9, and 0 ≤ t_1 < t_2 < t_3 < ... < t_{N-1} < t_N ≤ 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.

# Buggy version:
n, time = map(int, input().split())
T = list(map(int, input().split()))

cnt = time
tmp = T[0]
for t in T[1:]:
    if t <= time + time:
        cnt += t - tmp
    else:
        cnt += time
    tmp = t

print(cnt)

# Fixed version:
n, time = map(int, input().split())
T = list(map(int, input().split()))

cnt = time
tmp = T[0]
for t in T[1:]:
    if t <= tmp + time:
        cnt += t - tmp
    else:
        cnt += time
    tmp = t

print(cnt)

# Buggy version:
import itertools
n, t = map(int,input().split())
tl = list(map(int,input().split()))

water = 0
for i in range(n):
    if tl[i] <= t:
        water += tl[i]
    else:
        water += t
water += t
print(water)

# Fixed version:
import itertools
n, t = map(int,input().split())
tl = list(map(int,input().split()))

water = 0
for i in range(1,n):
    diff = tl[i]-tl[i-1]
    if diff <= t:
        water += diff
    else:
        water += t
water += t
print(water)

# Buggy version:
N,T = map(int,input().split());
t = [int(x) for x in input().split()];

end = 0;
ans = 0;
for i in range(N) :
    if end > t[i] :
        ans += t[i] + T - end;
        else :
        ans += T;
    end += t[i] + T;
    #print(ans,end);

print(ans); 

# Fixed version:
N,T = map(int,input().split());
t = [int(x) for x in input().split()];

end = 0;
ans = 0;
for i in range(N) :
    if end > t[i] :
        ans += t[i] + T - end;
    else :
        ans += T;
    end = t[i] + T;
    #print(ans,end);

print(ans);

# Buggy version:
N,T=map(int,input().split())
a=list(input().split())
ts=[]
for _ in range (len(a)):
    ts.append(int(a[_]))
    
YU=T

for i in range(1,N):
    if ts[i]-ts[i-1]<=T:
        YU=ts[i]+T
    else:
        YU+=T
print (YU)

# Fixed version:
N,T=map(int,input().split())
a=list(input().split())
ts=[]
for _ in range (len(a)):
    ts.append(int(a[_]))

YU=T

for i in range(1,N):
    if ts[i]-ts[i-1]<T:
        YU+=T-(T-(ts[i]-ts[i-1]))
    else:
        YU+=T
print (YU)

# Buggy version:
N, T=map(int, input().split())
a=list(map(int, input().split()))

ans=T

for i in range(N-1):
    space=a[i+1]-a[i]
    if space>=T:
        ans+=T
    else:
        loss=T-space
        ans+=T-loss


# Fixed version:
N, T=map(int, input().split())
a=list(map(int, input().split()))

ans=T

for i in range(N-1):
    space=a[i+1]-a[i]
    if space>=T:
        ans+=T
    else:
        loss=T-space
        ans+=T-loss

print(ans)

# Buggy version:
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
e = 0
s = 0
for n in t[1:]:
    if s + T < n:
        s = n
        ans += e + T
    e = n
ans += (e - s) + T
print(ans)

# Fixed version:
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
s = 0
e = T
for n in t[1:]:
    if e < n:
        ans += e - s
        s = n
    e = n + T
ans += e - s
print(ans)

# Buggy version:
n, T, *t = map(int, open(0).read().split())
print(sum(min(t[i+1] - t[i], T) for i in range(n)))

# Fixed version:
n, T, *t = map(int, open(0).read().split())
print(sum(min(t[i+1] - t[i], T) for i in range(n-1)) + T)

# Buggy version:
N, T = map(int,input().split())
t = list(map(int,input().split()))
t.append(T)

ans = 0
for n in range(N):
  ans += min(t[n+1]-t[n],T)
print(ans)

# Fixed version:
n,T=map(int,input().split())
t=list(map(int,input().split()))
t.append(t[-1]+T+1)
ans=0
for i in range(n):
  ans += min(T,t[i+1]-t[i])
print(ans)

# Buggy version:
n,T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
for i in range (n-1):
  if T >= t[i+1]-t[i]:
    ans=+(t[i+1]-t[i])
  else:
    ans=+T
    
print(ans+T)

# Fixed version:
n, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
tmp = t[0]
for i in range(1, n):
    if t[i] > t[i-1] + T:
        ans += t[i-1] - tmp + T
        tmp = t[i]
ans += t[n-1] - tmp + T
print(ans)

# Buggy version:
n, tx = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if t[i+1] <= tx:
        ans += t[i+1]
    else:
        ans += tx
print(ans+tx)

# Fixed version:
n,tmax = map(int,input().split())
t = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if t[i+1] - t[i]< tmax:
        ans += t[i+1] - t[i]
    else:
        ans += tmax
ans += tmax
print(ans)

# Buggy version:
n,t=map(int,input().split())
oyu=list(map(int,input.split()))
inl=[]
ans=n*t
for i in range(n-1):
  inl.append(oyu[i+1]-oyu[i])
for i in range(n-1):
  if inl[i]<t:
    ans-=t-inl[i]
print(ans)

# Fixed version:
n,t=map(int,input().split())
oyu=list(map(int,input().split()))
inl=[]
ans=n*t
for i in range(n-1):
  inl.append(oyu[i+1]-oyu[i])
for i in range(n-1):
  if inl[i]<t:
    ans-=t-inl[i]
print(ans)

# Buggy version:
N, T = input().split()

f = None
p = None
ans = 0
for t in map(int, input().split())
  if f is None:
    f = t
    p = t - f

  ans += T
  rest = p + T - (t - f)
  if rest > 0:
    ans -= rest

  p = t - f

print(ans)

# Fixed version:
N, T = map(int, input().split())

f = None
p = None
ans = 0
for t in map(int, input().split()):
  if f is None:
    f = t
    p = f - T

  ans += T
  rest = p + T - (t - f)
  if rest > 0:
    ans -= rest
  p = t - f

print(ans)

# Buggy version:
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
for i in range(N):
    if i == N - 1:
        ans += T
    else:
        ans += min(T, t[i + 1])
print(ans)


# Fixed version:
N,T=map(int, input().split())
t=list(map(int, input().split()))
ans=T
for i in range(1, N):
    x = (t[i]-t[i-1]) - T
    if x > 0:
        ans += T
    else:
        ans += T+x
print(ans)

# Buggy version:
N,T=map(int,input().split(' '))
times=[int(input()) for i in range(N)]
print(sum([min(T, times[i+1]-times[i] for i in range(N-1))])+times[-1])

# Fixed version:
N,T=map(int,input().split(' '))
times=list(map(int,input().split(' ')))
print(sum([min(T, times[i+1]-times[i]) for i in range(N-1)])+T)

# Buggy version:
N,T=map(int,input().split())
t=list(map(int,input().split()))

for i in range(0,len(t)-1):
        ans+=min(t[i+1]-t[i],T)
ans+=T
print(ans)

# Fixed version:
N,T=map(int,input().split())
t=list(map(int,input().split()))

ans=0
for i in range(0,len(t)-1):
        ans+=min(t[i+1]-t[i],T)
ans+=T
print(ans)

# Buggy version:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, T = map(int, input().split())

prev = None
ans = 0
for t in map(int, input().split()):
    if prev is not None:
        if t - prev < T:
            ans += t - prev
        else:
            ans += T
    prev = t
    print("ans:", ans)
ans += T


# Fixed version:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, T = map(int, input().split())

prev = None
ans = 0
for t in map(int, input().split()):
    if prev is not None:
        if t - prev < T:
            ans += t - prev
        else:
            ans += T
    prev = t
ans += T
print(ans)

# Buggy version:
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = T

for i in range(1, N):
    ans = min(T, t[i]-t[i-1])
print(ans)


# Fixed version:
N,T = list(map(int,input().split()))

t = list(map(int,input().split()))

ans = T

for i in range(N-1):
    ans += min(T,t[i+1]-t[i])
print(ans)

# Buggy version:
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    ans=min(a[i+1]-a[i],t)
ans+=t
print(ans)

# Fixed version:
n,t = map(int,input().split())
lis = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  ans += min(t,lis[i+1]-lis[i])
ans += t
print(ans)

# Buggy version:
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if a[i+1]-a[i]>=t:
    ans+=4
  else:
    ans+=(a[i+1]-a[i])
print(ans+t)

# Fixed version:
n,t=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
    if a[i]-a[i-1]<t:
        ans+=a[i]-a[i-1]
    else:
        ans+=t
ans+=t
print(ans)

# Buggy version:
def main():
    line=input()
    line=line.split(' ')
    n=line[0]
    t=line[1]
    line=input()
    line=line.split(' ')
    total=0
    for i in range(1,n):
        total+=min(t,line[i]-line[i-1])
    print(total)
    

if __name__=='__main__':
    main()

# Fixed version:
def main():
    line = input()
    line = line.split(' ')
    n = int(line[0])
    t = int(line[1])
    line = input()
    line = line.split(' ')
    total = 0
    for i in range(1, n):
        total += min(t, int(line[i]) - int(line[i - 1]))
    print(total+t)


if __name__ == '__main__':
    main()

# Buggy version:
satooh
N, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
	if t[i] + T <= t[i + 1]:
		ans += T
	else:
		ans += t[i + 1] - t[i]
ans += T
print(ans)


# Fixed version:
N,T = map(int, input().split())
t = list(map(int, input().split()))
total = 0 

for i in range(N-1):
    if t[i+1] - t[i] < T:
        total += t[i+1] - t[i]
    else:
        total += T
total += T
print(total)

# Buggy version:
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
for i in range(1,N):
  ans += min(T, t[i] - t[i-1])

print(ans)

# Fixed version:
N, T = map(int, input().split())

t = list(map(int, input().split()))

a = 0

for i in range(N-1):
    a += min(T, t[i+1]-t[i])

a += T

print(a)