cho.sh
Notes
Loading...

Choose Two Numbers With Minimum Difference

Time limit

2s

Memory limit

128 MB

Problem

You are given a sequence A[1], A[2], ..., A[N] of N integers. Choose two numbers from the sequence, possibly the same element, so that their absolute difference is at least M.

Find the smallest possible difference among all valid choices.

Input

The first line contains two integers N and M.

Each of the next N lines contains one integer, in order: A[1], A[2], ..., A[N].

Output

Print the smallest difference that is at least M.

It is guaranteed that at least one valid choice exists.

Constraints

  • 1 <= N <= 100,000
  • 0 <= M <= 2,000,000,000
  • 0 <= |A[i]| <= 1,000,000,000