noodle-jump

This time, Karan has decided to leave his laptop aside and take part in a long jump event - Noodle Jump. This is a special type of long jump event - it consists of a number of long jumps, of varying lengths.

Assuming the positive x-axis as the track, the coordinates where he can put his foot are given. He cannot put his foot on or in-between any other coordinates.

Given the geek that he is, he has already calculated the maximum jump he can make. As usual, he is short of time. He asks you the coordinate from where he will not be able to proceed further. Since this is a special type of long jump event, his jumps are measured only when he steps on the very first allowed coordinate.
Input:

The first line of the input contains two space separated integers N and K. N denotes the total number of coordinates where he can step and K denotes his maximum jumping capacity.

Next line contains N space separated integers - the coordinates where he can step.

Output:

The coordinate where his race ends.

Constraints:

1 ≤ N ≤ 10^6

1 ≤ K ≤ 10^6

0 ≤ coordinate ≤ 10^9

SAMPLE INPUT
4 1
1 2 3 5

SAMPLE OUTPUT
3

Source: hackerearth | Difficulty: EASY
Tags: Fundamentals


Solutions:
a,b=list(map(int,input().split()))
s=list(map(int,input().split()))
s=sorted(s)
for i in range(1,a):
	if s[i]-s[i-1]>b:
		print(s[i-1])
		break
else:
	print(s[a-1])


a,b=list(map(int,input().split()))
c=list(map(int,input().split()))
c.sort()
for i in range(a-1):
	if(c[i+1]-c[i])>b:
	  break;
print(c[i])


n,k = list(map(int,input().split()))
lst = [int(x) for x in input().split()]
lst.sort()
i=0
maxi = lst[i]
mini = lst[i]
i+=1
while maxi + k >= lst[i] and i!=n-1:
	mini = lst[i]
	maxi = lst[i]
	i+=1
print(mini)