Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/ikki-korsatkich-ayirmasi-k

Pair with difference k

Easy 1000 ms 128 MB 31%
Share

$n$ integers $a_{1}, a_{2}, \dots, a_{n}$ sorted in non-decreasing order and an integer $k \ge 0$ are given. If the array has two elements at different positions ($i \lt j$) whose difference equals $k$, print YES, otherwise NO:

$$a_{j} - a_{i} = k$$

Cells of the sorted array: two elements with difference k are joined by an arrow

Input

The first line contains two integers: $n$ and $k$. The second line contains $n$ integers $a_{i}$ in non-decreasing order.

Output

YES or NO.

Note

$2 \le n \le 2 * 10^{5}$
$-10^{9} \le a_{i} \le 10^{9}$
$0 \le k \le 2 * 10^{9}$

Examples

Input #1
5 5
1 3 4 6 9
Output #1
YES
Input #2
4 0
1 2 3 4
Output #2
NO

Sign in to submit a solution

Signing up is free and takes a minute.