Problem:
 Score : 300 points    Problem Statement In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.
Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower.
The i -th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?      Constraints  1 ≤ N ≤ 200,000  1 ≤ T ≤ 10^9  0 = t_1 < t_2 < t_3 < , ..., < t_{N-1} < t_N ≤ 10^9  T and each t_i are integers.         Input Input is given from Standard Input in the following format:  N  T  t_1  t_2 ... t_N       Output Assume that the shower will emit water for a total of X seconds. Print X .        Sample Input 1 2 4
0 3      Sample Output 1 7  Three seconds after the first person pushes the water, the switch is pushed again and the shower emits water for four more seconds, for a total of seven seconds.       Sample Input 2 2 4
0 5      Sample Output 2 8  One second after the shower stops emission of water triggered by the first person, the switch is pushed again.       Sample Input 3 4 1000000000
0 1000 1000000 1000000000      Sample Output 3 2000000000       Sample Input 4 1 1
0      Sample Output 4 1       Sample Input 5 9 10
0 3 5 7 100 110 200 300 311      Sample Output 5 67

Solution (Python):
N, T = map(int, input().split())
Ts = list(map(int,input().split()))

ans = 0
right = 0
for t in Ts:
    if right <= t: ans += T
    else: ans += t + T - right
    right = t + T

print(ans)

Solution (Python):
N,T = map(int,input().split())
t = list(map(int,input().split()))

if len(t) == 1:
    print(T)
    exit()

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

print(X)

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

Solution (Python):
_,t=map(int,input().split())
l=list(map(int,input().split()))
s=0
for i in range(len(l)-1):
  j=l[i+1]-l[i]
  if j<t:s+=j
  else:s+=t
s+=t
print(s)

Solution (Python):
n,t=map(int,input().split())
tl=list(map(int,input().split()))
s=t
for i in range(1,n):
    s+=min(tl[i]-tl[i-1],t)
print(s)

Solution (Python):
(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
count = t
for i in range(1, len(a)):
    count -= max(0, t - (a[i] - a[i-1]))
    count += t
print(count)

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

Solution (Python):
n, T = map(int, input().split())
t = list(map(int, input().split()))
ans = T
for i in range(1, n):
    if t[i]-t[i-1] <= T:
        ans += t[i]-t[i-1]
    else:
        ans += T
print(ans)

Solution (Python):
N, T = map(int, input().split())
time_array = list(map(int, input().split()))       
sum_time = 0
for i in range(len(time_array)-1):
    if T > time_array[i+1] - time_array[i]:
        sum_time += time_array[i+1] - time_array[i]
    else:
        sum_time += T

print(sum_time + T)

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))
res = 0
start = 0
for i in range(N):
    if t[i] - start > T:
        res += T
        start = t[i]
    else:
        res += t[i] - start
        start = t[i]
print(res+T)

Solution (Python):


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

estime = T
for i in range(1,N):
    if tn[i] - tn[i-1] > T:
        estime += T
    else:
        estime += tn[i] - tn[i-1]

print(estime)

Solution (Python):
def 解():
    iN ,iT = [int(_) for _ in input().split()]
    aT = [int(_) for _ in input().split()]
    tb = 0
    iAns = 0
    for ti in aT[1:]:
        if ti - tb <= iT:
            iAns += ti -tb
        else:
            iAns += iT
        tb = ti
    iAns += iT
    print(iAns)
解()

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))
t.append(10000000000)
ans = 0
for i in range(N):
    if t[i] + T <= t[i+1]:
        ans += T
    else:
        ans += t[i+1] - t[i]
print(ans)

Solution (Python):
n,t = map(int,input().split())
a = list(map(int,input().split()))
dif = []*n
for i in range(len(a)-1):
    dif.append(a[i+1]-a[i])

stan = [j for j in dif if j >= t]
suf = [k for k in dif if k < t]
print(sum(suf) + (t)*(len(stan)+1))

Solution (Python):
n,s=map(int,input().split())
t=list(map(int,input().split()))
ans=t[0]
t_sum=t[0]
for i in range(1,n):
    if t[i-1]+s<t[i]:
        ans +=s
    else:
        ans +=t[i]-t[i-1]
ans +=s
print(ans)

Solution (Python):
N, T = map(int, input().split())
t_list = list(map(int, input().split()))
i = 0
duration = 0
while i < N -1:
    diff = t_list[i+1] - t_list[i]
    if diff > T:
        duration += diff - T
    i += 1
print(t_list[-1] - duration + T)

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))

answer = t[-1] + T
t_end = 0
for ti in t:
    answer -= max(ti - t_end, 0)
    t_end = ti + T
print(answer)

Solution (Python):
n, t = map(int, input().split())
tn = list(map(int, input().split()))
x = 0

for i in range(n-1):
    if tn[i+1] - tn[i] >= t:
        x += t
    else:
        x += tn[i+1] - tn[i]
print(x + t)

Solution (Python):
N,T = map(int, input().split())
t_list = list(map(int, input().split()))

ans = T

for i in range(N-1):
    diff = t_list[i+1] - t_list[i]
    if T >= diff:
        ans += diff
    else:
        ans += T
    
print(ans)

Solution (Python):
n,t = map(int,input().split())
a = list(map(int,input().split()))
s = t
for i in range(0,n-1):
  s += min(t,a[i+1]-a[i])
print(s)

Solution (Python):
N,T = map(int,input().split())
Ts = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    t = Ts[i]
    tt = Ts[i + 1]

    if tt <= t + T:
        ans += tt - t
    else:
        ans += T

ans = ans + T

print(ans)

Solution (Python):
N, T = map(int, input().split())
Push = [int(i) for i in input().split()]
Total = T

if N >= 2:
    for i in range(1, N):
        if Push[i] >= Push[i-1] + T:
            Total += T
        else:
            Total += Push[i] - Push[i-1]

print(Total)

Solution (Python):
n, t = map(int, input().split())
listT=list(map(int, input().split()))

index=1
sum=0
while index < len(listT):
    if listT[index] - listT[index-1]<t:
        sum += listT[index] - listT[index-1]
    else:
        sum+=t
    index+=1
sum+=t

print(sum)

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))
sa = [t[i+1]-t[i] for i in range(N-1)]

ans = 0
for i in sa:
    ans += min(T, i)
print(ans+T)

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))
sa = [t[i+1]-t[i] for i in range(N-1)]
hazimari = t[0]
las = t[0]
ans = 0

for i in range(N-1):
    
    if sa[i] <= T:
        las = t[i+1]
        
    else:
        ans += las-hazimari+T
        hazimari = t[i+1]
        las = t[i+1]
        
if hazimari != las:
    ans += las -hazimari+T
else:
    ans += T

print(ans)

Solution (Python):
N, T = map( int, input().split())
S = list( map( int, input().split()))
S.append(10**10)
ans = 0
now = 0
for i in range(1,N+1):
    ans += min( S[i] - now, T)
    
    
    
    
    now = S[i]
print(ans)

Solution (Python):
N, T = map( int, input().split())
S = list( map( int, input().split()))
S.append(10**10)
ans = 0
now = 0
for i in range(1,N+1):
    if S[i] - now >= T:
        ans += T
    else:
        ans += S[i] - now
    now = S[i]
print(ans)

Solution (Python):
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=0
for i in range(a-1):
    d+=min(b,c[i+1]-c[i])
print(d+b)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, T = map(int, input().split())
    end = 0
    ans = 0
    for t in list(map(int, input().split())):
        ans += (t + T) - max(t, end)
        end = t + T
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


def main():
    N, T = li_input()
    Ts = li_input()

    L = []

    i = 0
    while i < len(Ts):
        l = [Ts[i]]

        while i + 1 < len(Ts) and Ts[i + 1] - Ts[i] <= T:
            i += 1

        l.append(Ts[i] + T)
        i += 1
        L.append(l)

    ans = 0

    for l in L:
        ans += (l[1] - l[0])

    print(ans)



main()

Solution (Python):
na = lambda: list(map(int, input().split()))
n, t = na()
l = na()
ans = n * t
for i in range(n-1):
    diff = l[i] + t - l[i+1]
    if diff > 0:
        ans -= diff
print(ans)

Solution (Python):
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n,x = li()
t = li()

ans = 0

for i in range(n-1):
    ans += min(t[i+1] - t[i], x)

ans += x

print(ans)

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))

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

Solution (Python):
N,T = map(int,input().split())
ts = list(map(int,input().split()))

prev = ts[0]
ans = 0
for t in ts[1:]:
    ans += min(T, t - prev)
    prev = t
ans += T
print(ans)

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))
sumT = T
for i in range(1, N):
    sumT += T
    S = t[i]
    G = t[i - 1] + T
    if G > S:
        sumT -= (G - S)
print(sumT)

Solution (Python):
N, T = map(int, input().split())
t_list = list(map(int, input().split()))

ans = 0
t_old = -T

for t in t_list:
    diff = t - t_old
    if diff <= T:
        ans += diff
    else:
        ans += T

    t_old = t

print(ans)

Solution (Python):
N, T, *L = map(int, open(0).read().split())
print(T + sum(min(L[i + 1] - L[i], T) for i in range(N - 1)))

Solution (Python):
N, T, *L = map(int, open(0).read().split())
print(sum(min(T, b - a) for a, b in zip(L, L[1:] + [float('inf')])))

Solution (Python):
N, T, *L = map(int, open(0).read().split())
print(L[-1] + T - sum(b - a - T for a, b in zip(L, L[1:]) if b - a > T))

Solution (Python):
N, T, *L = map(int, open(0).read().split())
a, d = T, 0
for t in L:
    if a < t:
        d += t - a
    a = t + T
print(a - d)

Solution (Python):
n, t0 = list(map(int, input().split()))
t =  list(map(int, input().split()))

total = 0
for i in range(1,n):
    if t[i] - t[i-1] > t0:
        total += t0
    else:
        total += t[i] - t[i-1]
total += t0
print(total)

Solution (Python):
N,T=map(int,input().split())
t=list(map(int,input().split()))
count=0
for i in range(1,N):
    count+=min(T,t[i]-t[i-1])
print(count+T)

Solution (Python):
N,T = map(int,input().split())
t = list(map(int,input().split()))

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

Solution (Python):
N, T = map(int, input().split())
t = map(int, input().split())
duration = 0
end = 0
for ti in t:
  duration += ti + T - max(ti, end)
  end = ti + T
print(duration)

Solution (Python):
N, T = map(int, input().split())
Tlist = list(map(int, input().split()))

ans = 0
for i in range(1,N):
  dif = Tlist[i] - Tlist[i-1]
  if dif >= T:
    ans += T
  else:
    ans += dif

ans += T

print(ans)

Solution (Python):
N,T=map(int, input().split())
TN=list(map(int, input().split()))
a=[0]
b=[]
if N==1:
    print(N)
    exit()
for i in range(1,N):
    if TN[i]>TN[i-1]+T:
        a.append((TN[i-1]+T)-a[-1])
        b.append(a[-1])
        a=[]
        a.append(TN[i])
    if i==N-1:
        a.append(TN[i]+T-a[-1])
        b.append(a[-1])
print(sum(b))

Solution (Python):

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

Solution (Python):


n, t = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [A[i+1]-A[i] for i in range(n)]
ans = 0
for b in B:
    ans += min(t, b)
ans += t
print(ans)

Solution (Python):
N, T = map(int, input().split())

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

sumTime = 0

for i in range(N-1):
    dt = tList[i+1] - tList[i]
    if dt < T:
        sumTime += dt
    else:
        sumTime += T

sumTime += T

print(sumTime)

Solution (Python):
n,t = map(int, input().split())
a = list(map(int,input().split()))
a.append(float("inf"))
ans = 0
for i in range(n):
  if a[i+1] - a[i] >= t:
    ans += t
  else:
    ans += a[i+1] - a[i]
print(ans)

Solution (Python):
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
count = 0
for i in range(N-1):
    if A[i + 1] - A[i] > T:
        count = count + T
    else:
        count = count + A[i + 1] - A[i]
print(count + T)

Solution (Python):
n,t = map(int,input().split())
a = list(map(int,input().split()))

res = 0
left = 0
right = 0
for i in a:
    if i-right<=t:
        right = i
    else:
        res += right - left + t
        left = i
        right = i
    
else:
    res += right - left + t

print(res)

Solution (Python):
import numpy as np
n, t = map(int, input().split())
a = list(map(int, input().split()))

result = 0
for i, v in enumerate(a[1:], 1):
    result += min(a[i - 1] + t, v) - a[i - 1]
print(result + t)

Solution (Python):
N, T = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
ans = T

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

print(ans)

Solution (Python):

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

ans = 0

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

Solution (Python):
n, t = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
a.append(10000000000)
for i in range(1, n + 1):
  ans += min(a[i] - a[i-1], t)
print(ans)

Solution (Python):
n, time = [int(_) for _ in input().split()]
t = [int(_) for _ in input().split()]

off_total = 0
for i in range(0, n-1):
    if t[i+1] - t[i] > time:
        off_total += t[i+1] - t[i] - time

print(t[-1] + time - off_total)

Solution (Python):


def main():
    n, t = map(int, input().split())

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

    not_water = []
    for i in range(1, n):
        if t_list[i] - t_list[i-1] > t:
            not_water.append(t_list[i] - t_list[i-1] - t)
    print(max(t_list) + t - sum(not_water))

if __name__ == '__main__':
    main()

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))
dts = [a - b for a, b in zip(t[1:], t[:-1])]
print(sum(min(dt, T) for dt in dts) + T)

Solution (Python):
N, T = [int(v) for v in input().split()]
t = [int(v) for v in input().split()]

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

Solution (Python):
n, t = map(int, input().split(" "))
u = tuple(map(int, input().split(" ")))

print(sum([min(t, u[i+1]-u[i]) for i in range(n-1)]) + t)

Solution (Python):
n, T = list(map(int, input().split()))
t = list(map(int, input().split()))

end = T
ans = T
for i in range(1, n):
    if t[i] < end:
        ans = ans - (end-t[i]) + T
    else:
        ans += T
    end = t[i] + T
    
print(ans)

Solution (Python):
N,T=map(int,input().split())
l=list(map(int,input().split()))
r=sum(min(T,l[i]-l[i-1]) for i in range(1,N))+T
print(r)

Solution (Python):
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+T)

Solution (Python):

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

start = -10
stop = -10
ans = 0
flag = False

for t in tt:
	if stop < t:
		ans += stop-start
		start = t
		stop = t + T
	else:
		stop = t + T

ans += stop-start

print(ans)

Solution (Python):
def inpl(): return input().split()
N, T = map(int, inpl())
t = list(map(int, inpl()))

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

Solution (Python):
N,T = map(int,input().split())
a = list(map(int,input().split()))

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

Solution (Python):
n, t = map(int, input().split())
t_list = list(map(int, input().split()))

total_seconds = 0
prev_timing = t_list[0]

for timing in t_list[1:]:
  if timing - prev_timing < t:
    total_seconds += timing - prev_timing
  else:
    total_seconds += t
  prev_timing = timing
total_seconds += t

print(total_seconds)

Solution (Python):
N,T=(int(i) for i in input().split())
t = [int(i) for i in input().split()]
a=0
for b in range(N-1):
    if (t[b+1] - t[b]) < T:
        a = a + t[b+1] - t[b]
    else:
        a = a + T
a = a+T
print(a)

Solution (Python):
N, T = (int(i) for i in input().split())
t = [int(i) for i in input().split()]

tt = [0 for i in range(len(t)-1)]
for i in range(len(tt)):
    tt[i] = t[i+1] - t[i]

time = T
for i in tt:
    if i < T:
        time += i
    else:
        time += T

print(time)

Solution (Python):


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

ans = T
for i in range(1,N):

    if tN[i] - tN[i-1] < T:
        ans += tN[i] - tN[i-1]
    else:
        ans += T

print(ans)

Solution (Python):
N, T = map(int, input().split())
t = [int(x) for x in input().split()]

sum_over = 0

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

Solution (Python):
n,t = map(int,input().split())

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

now=t
ans=0

for i in range(1,n):
    if now>a[i]:
        ans+=t-now+a[i]
    else:
        ans+=t
    now=a[i]+t

print(ans+t)

Solution (Python):
n, t = map(int,raw_input().split())

arr = map(int,raw_input().split())

ans = 0
for i in range(n-1):
	if arr[i] + t > arr[i+1]:
		ans += arr[i+1]-arr[i]

	else :
		ans += t

print ans+t

Solution (Python):
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)

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

Solution (Python):
n,t = input().split()
N = int(n)
T = int(t)
t_list = []

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

sum_time = 0

for j in range(1,len(t_list)):
	if(t_list[j]-t_list[j-1] <= T):
		sum_time += t_list[j]-t_list[j-1]
	elif(t_list[j]-t_list[j-1] > T):
		sum_time += T

sum_time += T
print(sum_time)

Solution (Python):

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

ans = 0

for i in range(1, N):
    if T_lst[i] <= T_lst[i - 1] + T:
        ans += T_lst[i] - T_lst[i - 1]
    else:
        ans += T

ans += T
print(ans)

Solution (Python):
N,T = map(int, input().split())
t = list(map(int, input().split()))
x = T

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

Solution (Python):
N,T = map(int, input().split())
t = list(map(int, input().split()))
x = T

for i in range(1,N):
    if t[i]-t[i-1] >= T:
        x += T
    elif t[i]+T > T:
        x += t[i]-t[i-1]
print(x)

Solution (Python):
N, T = map(int, input().split())
input_list = [int(i) for i in input().split()]

sum_time = 0

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

print(sum_time + T)

Solution (Python):
N, T = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
ans = 0
end = 0
for i in range(N):
    nextEnd = t[i] + T
    ans += nextEnd - max(end, t[i])
    end = nextEnd

print(ans)

Solution (Python):
n,t=map(int, input().split())
a=list(map(int, input().split()))
count=t
for i in range(1,n):
    count+=t
    if a[i-1]+t>a[i]:
        count-=t+a[i-1]-a[i]
print(count)

Solution (Python):
N,T=map(int,input().split())
t = [int(i) for i in input().split()]
tot = 0
l = len(t)
i = 0
while i < l-1:
  if t[i+1]-t[i] >= T:
    tot += T
    i += 1
  else:
    tot += t[i+1]-t[i]
    i += 1
tot += T
print(tot)

Solution (Python):
N,T = map(int,input().split())
src = list(map(int,input().split()))
rem = prev = ans = 0
for t in src:
    if rem <= t-prev:
        ans += rem
    else:
        ans += t-prev
    rem = T
    prev = t

ans += rem
print(ans)

Solution (Python):
def m():
    n, T = map(int, input().split())
    t = list(map(int, input().split()))
    ans = 0
    for i in range(1, n):
        diff = abs(t[i-1] - t[i])
        if diff <= T:
            ans += diff
            continue
        ans += T
    ans += T
    return ans


print(m())

Solution (Python):
n, t = map(int, input().split())
a = list(map(int, input().split()))
cur = 0
s = 0
for i in range(n):
    if cur < a[i]:
        s += t
    elif cur < a[i] + t:
        s += min(t, a[i] + t - cur)
    cur = a[i] + t
print(s)

Solution (Python):
N, T = map(int,input().split())
t = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    ans += min(t[i] - t[i-1], T)
print(ans+T)

Solution (Python):
n,T = map(int, input().split())
t = list(map(int,input().split()))

ans = 0
end_at = 0
for s in t:
    if end_at >= s:
        ans += s+T-end_at
    else:
        ans += T
    end_at = s+T
print(ans)

Solution (Python):
def c_sentou(N, T, time):
    time.append(float('inf'))  
    ans = 0
    for i in range(N):
        ans += min(T, time[i + 1] - time[i])
    return ans

N,T = [int(i) for i in input().split()]
time = [int(i) for i in input().split()]
print(c_sentou(N, T, time))

Solution (Python):
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 += T
    else:
        Ans += A[i] - A[i-1]
else:
    Ans += T
print(Ans)

Solution (Python):
N,T=map(int,input().split())
TM=[int(x) for x in input().split()]

waste=0
for i in range(N-1):
  if TM[i+1]-TM[i]<T:
    waste+=(T-(TM[i+1]-TM[i]))
print(N*T-waste)

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))
X = [0 for i in range(N)]

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

print(X[-1]+T)

Solution (Python):
n, t = (int(i) for i in input().split())
ts = [int(i) for i in input().split()]
between = []
for i in range(1,n):
    between.append(ts[i]-ts[i-1])
    
ans = t
for d in between:
    if d > t:
        ans = ans + t
    else:
        ans = ans + d
print(ans)

Solution (Python):
N, T = map(int,input().split())
S = list(map(int,input().split()))

k = 0
s = 0
ans = 0
for p in S:
    if k > p:
        k = p + T
    else:
        ans += k-s
        s = p
        k = p + T

print(ans+k-s)

Solution (Python):
def getinputdata():
    
    array_result = []

    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if (data != ""):

                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:

        return array_result


arr_data = getinputdata()

n = int(arr_data[0][0])
t = int(arr_data[0][1])

arr = [int(x) for x in arr_data[1]]

mysum = 0


for i in range(0, n-1):

    if arr[i + 1] - arr[i] >= t:

        mysum += t
    else:

        mysum += arr[i + 1] - arr[i]

print(mysum+t)

Solution (Python):
n, t = map(int, input().split())
times = list(map(int, input().split()))
total = 0
for i in range(1, n):
  if times[i] - times[i-1] >= t:
    total += t
  else:
    total += times[i] - times[i-1]

print(total + t)

Solution (Python):





if __name__ == '__main__':
    n, intervel = list(map(int, input().split()))
    ts = list(map(int, input().split()))
    ts += [ts[-1] + intervel]

    total_t = 0
    previous_t = ts[0]

    
    
    for i in range(1, n + 1):
        current_t = ts[i]
        total_t += min(current_t - previous_t, intervel)
        previous_t = current_t

    print(total_t)

Solution (Python):





if __name__ == '__main__':
    n, intervel = list(map(int, input().split()))
    ts = list(map(int, input().split()))
    ts += [ts[-1] + intervel]

    total_t = 0
    previous_t = ts[0]

    for i in range(1, n + 1):
        current_t = ts[i]

        if (previous_t + intervel) > current_t:
            total_t += max(0, current_t - previous_t)
        else:
            total_t += intervel

        previous_t = current_t

    print(total_t)

Solution (Python):
N, T = map(int, input().split(' '))
time = list(map(int, input().split(' ')))
Sumtime = 0
prev = 0
for i in time:
    if i == 0:
        continue
    elif i - prev >= T:
        Sumtime += T
    else:
        Sumtime += i - prev
    prev = i
print(Sumtime + T)

Solution (Python):
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]
    elif t<a[i]-a[i-1]:
        ans+=t
print(ans+t)

Solution (Python):
def calc(a, t):
	ans = t
	for i in range(0, len(a)-1):
		if a[i+1]-a[i] < t: ans = ans + a[i+1] - a[i]
		else: ans = ans + t
	return ans

N, T = map(int, raw_input().split())
timelist = map(int, raw_input().split())

print calc(timelist, T)

Solution (Python):
N,T = map(int,input().split())
src = list(map(int,input().split()))

ans = now = 0
for t in src:
    ans += min(T, t-now)
    now = t
print(ans + T)

Solution (Python):
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
res = 0

res = max(b)+a[1]
for i in range(1, len(b)):
    res -= abs(b[i]-b[i-1])-a[1] if abs(b[i]-b[i-1])-a[1] > 0 else 0

print(res)

Solution (Python):
n,m=map(int,input().split())
w=m
s=list(map(int,input().split()))
for i in range(n-1):
    t=s[i+1]-s[i]
    if m>t:
        w+=t
    else:
        w+=m
print(w)

Solution (Python):
N, T = map(int, input().split())
t = list(map(int, input().split()))
sum = 0
for i in range(N-1):
    if t[i + 1] - t[i] < T:
        sum += t[i + 1] - t[i]
    else:
        sum += T
sum += T
print(sum)

Solution (Python):
n,t=map(int,input().split())
tt=list(map(int,input().split()))
tt.append(10**10)

ans=0
i=0

while i<n:
    ans+=min(tt[i+1]-tt[i],t)
    i+=1
print(ans)

Solution (Python):
tmp = list(map(int,input().split()))
n,t = tmp[0],tmp[1]
ts = list(map(int,input().split()))
ans = t
for i in range(n-1):
  if ts[i+1] - ts[i] < t:
    ans += ts[i+1] - ts[i]
  else:
    ans += t
print(ans)

Solution (Python):
n,t = map(int,input().split())
tl =list(map(int,input().split()))

    
s = 0
for i in range(n-1):
    p = tl[i + 1] - tl[i]
    if p >= t:
        s = s + t
    else:
        s = s + p
        
s = s + t
print(s)

Solution (Python):
n, t = map(int, input().split())
times = list(map(int, input().split()))
total = 0
for i in range(1, n):
  if times[i] - times[i-1] >= t:
    total += t
  else:
    total += times[i] - times[i-1]

print(total + t)

Solution (Python):
n, t = map(int, input().split())
switches = list(map(int, input().split()))
time = 0
for i in range(1, n):
    if switches[i] - switches[i-1] < t:
        time += switches[i] - switches[i-1]
    else:
        time += t
time += t
print(time)

Solution (Python):
n, t = map(int, input().split())
a = [int(x) for x in input().split()]
c = 0
s = 0
e = 0
for k in a:
    if k >= e:
        c += e - s
        s = k
        e = k + t
    else:
        e = k + t
c += e - s
print(c)

Solution (Python):
n,t=map(int,input().split());s=t
*a,=map(int,input().split())
for i in range(~-n):
    if a[-~i]-a[i]<t:s+=a[-~i]-a[i]
    else:s+=t
print(s)

Solution (Python):
n,t = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
answer,start = 0,0
if len(a)==1: answer = t
for i in range(1,n):
	if a[i] > a[i-1]+t:
		end = a[i-1]+t
		answer += end-start
		start = a[i]
	if i == n-1:
		end = a[i]+t
		answer += end-start
print(answer)

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