A video player plays a game in which the character competes in a hurdle race.  Hurdles are of varying heights, and the characters have a maximum height they can jump.  There is a magic potion they can take that will increase their maximum jump height by $\mbox{1}$ unit for each dose.  How many doses of the potion must the character take to be able to jump all of the hurdles.  If the character can already clear all of the hurdles, return $\mbox{0}$.

Example 

$height=[1,2,3,3,2]$ 

$k=1$  

The character can jump $\mbox{1}$ unit high initially and must take $3-1=2$ doses of potion to be able to jump all of the hurdles.   

Function Description  

Complete the hurdleRace function in the editor below.    

hurdleRace has the following parameter(s):  

int k: the height the character can jump naturally  
int height[n]: the heights of each hurdle  

Returns  

int: the minimum number of doses required, always $\mbox{0}$ or more

Input Format

The first line contains two space-separated integers $n$ and $\boldsymbol{\mbox{k}}$, the number of hurdles and the maximum height the character can jump naturally. 

The second line contains $n$ space-separated integers $\textit{height}[i]$ where $0\leq i<n$.

Constraints

$1\le n,k\le100$  
$1\leq height[i]\leq100$  

Sample Input 0
5 4
1 6 3 5 2

Sample Output 0
2

Explanation 0

Dan's character can jump a maximum of $k=4$ units, but the tallest hurdle has a height of $h_1=6$:

To be able to jump all the hurdles, Dan must drink $6-4=2$ doses.

Sample Input 1
5 7
2 5 4 5 2

Sample Output 1
0

Explanation 1

Dan's character can jump a maximum of $k=7$ units, which is enough to cross all the hurdles:

Because he can already jump all the hurdles, Dan needs to drink $\mbox{0}$ doses.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(0, max(height) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(0, max(height) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(max(height) - k, 0))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(0, max(height) - k))


(_, k) = [int(p) for p in input().split()]
hurdles = [int(p) for p in input().split()]
maxx = max(hurdles)
if maxx > k:
	print(maxx - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
a = max(height)
print(max(a - k, 0))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
max_height = max(height)
print(max(0, max_height - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(0, max(height) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
h = max(height)
print(max(h - k, 0))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if k >= max(height):
	print(0)
else:
	print(max(height) - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
tmp = max(height) - k
if tmp < 0:
	tmp = 0
print(tmp)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
res = max(height) - k
if res > 0:
	print(max(height) - k)
else:
	print(0)


(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if max(height) > k:
	print(max(height) - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if k > max(height):
	print(0)
else:
	print(max(height) - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
m = max(height)
if m > k:
	print(m - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(0, max(height) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
ans = max(height) - k
if ans < 0:
	print(0)
else:
	print(ans)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
count = 0
for i in height:
	if i > k:
		count += i - k
		k = i
print(count)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(max(height) - k, 0))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
tot = 0
for h in height:
	if h > k:
		tot += h - k
		k += h - k
print(tot)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
h = list(map(int, input().strip().split(' ')))
x = max(h) - k
if x > 0:
	print(x)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
drink = max(height) - k
if drink <= 0:
	print(0)
else:
	print(drink)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
mh = max(height)
if k >= mh:
	print(0)
else:
	print(mh - k)


(n, k) = [int(a) for a in input().split()]
h = [int(a) for a in input().split()]
m = max(h)
print(max(0, m - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
maxh = max(height)
if maxh < k:
	print(0)
else:
	print(maxh - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(max(height) - k, 0))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(0, max(height) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
maxi = max(height)
if maxi - k > 0:
	print(maxi - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if k >= max(height):
	print(0)
else:
	print(max(height) - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
mx = k
for x in height:
	mx = max(mx, x)
print(mx - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
m = max(height)
if m > k:
	print(m - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(height) - k if max(height) - k > 0 else 0)


import sys
(N, K) = input().strip().split(' ')
(N, K) = [int(N), int(K)]
height = list(map(int, input().strip().split(' ')))
if max(height) - K > 0:
	print(max(height) - K)
else:
	print(0)


(n, k) = map(int, input().split())
heights = list(map(int, input().split()))
print(max(0, max(heights) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
mh = max(height)
if mh < k:
	print(0)
else:
	print(mh - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if max(height) <= k:
	print(0)
else:
	print(max(height) - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
drink = max(height) - k
print(drink > 0 and drink or 0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
x = max(height)
if x > k:
	print(x - k)
else:
	print('0')


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
x = max(height)
if x > k:
	print(x - k)
else:
	print('0')


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(max(height) - k, 0))


(n, k) = map(int, input().split())
a = max(map(int, input().split()))
print(max(0, a - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
maximum = max(height)
diff = k - maximum
result = 0 if diff >= 0 else abs(diff)
print(result)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
maxHeight = max(height)
if maxHeight > k:
	print(maxHeight - k)
else:
	print(0)


(n, k) = map(int, input().split())
a = max(map(int, input().split()))
if k >= a:
	print(0)
else:
	print(a - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
left = max(height)
if left < k:
	print(0)
else:
	print(left - k)


(n, k) = map(int, input().split())
maxheight = max(map(int, input().split()))
print(max(0, maxheight - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
max_height = max(height)
if max_height < k:
	print('0')
else:
	print(max_height - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
ans = max(height) - k
if ans < 0:
	print('0')
else:
	print(ans)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
result = max(height) - k
if result <= 0:
	print(0)
else:
	print(result)


(n, k) = map(int, input().split())
h = [int(i) for i in input().split()]
print(max(max(h) - k, 0))


(n, k) = map(int, input().strip().split())
arr = map(int, input().strip().split())
print(max(0, max(arr) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
m = max(height) - k
if m > 0:
	print(m)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
magic = 0
for i in height:
	if i > k:
		if i - k > magic:
			magic = i - k
print(magic)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
mb = 0
for x in height:
	if x > k:
		mb += x - k
		k = x
print(mb)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
mh = max(height)
if mh > k:
	print(mh - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
temp = max(height)
temp = temp - k
if temp < 0:
	print(0)
else:
	print(temp)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
tallest_hurdle = sorted(height, reverse=True)[0]
if tallest_hurdle > k:
	print(tallest_hurdle - k)
else:
	print(0)


(n, k) = tuple(map(int, input().split()))
hurdles = list(map(int, input().split()))
max_h = max(hurdles)
if max_h > k:
	print(max_h - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if k > max(height):
	print(0)
else:
	print(max(height) - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
maxm = max(height)
if k > maxm:
	print(0)
else:
	print(maxm - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if k >= max(height):
	print(0)
else:
	print(max(height) - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
temp = max(height) - k
print(temp if temp > 0 else 0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
tot = 0
if max(height) > k:
	print(max(height) - k)
else:
	print(0)


(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
a = max(height)
if a > k:
	print(a - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
c = 0
for i in height:
	if not i <= k:
		c = c + (i - k)
		k = i
print(c)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
print(max(0, max(height) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if max(height) > k:
	print(max(height) - k)
else:
	print('0')


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
dif = max(height) - k
if dif >= 0:
	print(dif)
else:
	print(0)


(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
h = max(height)
print(h - k if h > k else 0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
potion = 0
max = 0
for i in height:
	if i > max:
		max = i
potion = max - k
if potion <= 0:
	potion = 0
print(potion)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
highest = 0
for h in height:
	highest = max(highest, h)
if highest > k:
	print(highest - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
res = 0
for h in height:
	if k < h:
		res += h - k
		k = h
print(res)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
a = max(height)
if a - k > 0:
	print(a - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
m = max(height)
dif = m - k
if dif < 1:
	print(0)
else:
	print(dif)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
count = 0
for i in range(n):
	if k >= height[i]:
		continue
	else:
		while k < height[i]:
			count += 1
			k += 1
print(str(count))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
units = max(height) - k
if units > 0:
	print(units)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
ans = 0
for i in height:
	if k < i:
		ans += i - k
		k = i
print(ans)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
max_height = max(height)
if max_height <= k:
	print(0)
else:
	print(max_height - k)


import sys
(n, k) = map(int, input().split())
height = list(map(int, input().split()))
print(max(height) - k if max(height) - k > 0 else 0)


s = input().split(' ')
k = input().split(' ')
n = int(s[1])
ok = int(k[0])
for x in k:
	if int(x) > ok:
		ok = int(x)
if ok > n:
	print(str(ok - n))
else:
	print('0')


def solution(arr, height):
	count = 0
	for i in arr:
		if i <= height:
			pass
		else:
			count += i - height
			height += i - height
	return count
(size, height) = [int(temp) for temp in input().strip().split()]
arr = [int(temp) for temp in input().strip().split()]
ans = solution(arr, height)
print(str(ans))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
x = max(height) - k
if x < 0:
	print('0')
else:
	print(x)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
m = max(height)
if k > m:
	print(0)
else:
	print(m - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
max_h = max(height)
print(max_h - k) if k < max_h else print(0)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
print(max(0, max(lst) - k))


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
height.sort()
if height[-1] <= k:
	print(0)
else:
	print(height[-1] - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
m = max(height) - k
if m > 0:
	print(m)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
a = height[0]
for x in height:
	if x > a:
		a = x
if a > k:
	print(a - k)
else:
	print('0')


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
m = max(height)
res = m - k
if res > 0:
	print(res)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split()))
height = sorted(height, reverse=True)
if height[0] > k:
	print(height[0] - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
maxh = max(height)
if k <= maxh:
	print(maxh - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
height = sorted(height)
if k > height[-1]:
	print(0)
else:
	print(height[-1] - k)


(n, k) = input().split()
(n, k) = (int(n), int(k))
a = [int(j) for j in input().split()]
p = max(a)
if p < k:
	print(0)
else:
	print(p - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
if max(height) > k:
	print(max(height) - k)
else:
	print('0')


def main():
	(_, k) = map(int, input().split())
	max_hurdle = max(map(int, input().split()))
	print(max(max_hurdle - k, 0))
main()


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
height.sort()
if height[n - 1] < k:
	print('0')
else:
	print(height[n - 1] - k)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
ans = max(height) - k
if ans < 0:
	ans = 0
print(ans)


c = 1
cases = 1
while c <= cases:
	[n, k] = [int(i) for i in input().split()]
	h = [int(i) for i in input().split()]
	ans = 0
	for i in h:
		if i > k:
			ans += i - k
			k += i - k
	print(ans)
	c = c + 1


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
a = max(height)
if a > k:
	print(a - k)
else:
	print(0)


import sys
(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
m = max(height)
if k >= m:
	print(0)
else:
	print(m - k)