Skip to content
UPEEC

Pairs with Difference K

Medium#arrays#hashing· solved by 0 · time limit 2.0 s

Count the distinct value pairs (x,y)(x, y) in the array with y−x=ky - x = k. (For k=0k = 0, count values that appear at least twice.)

Input

nn, then nn integers, then kk.

Output

The number of distinct pairs.

Constraints

1≤n≤1051 \le n \le 10^5, 0≤k≤1090 \le k \le 10^9

Sample 1

Input

5
3 1 4 1 5
2

Output

2

Sample 2

Input

5
1 3 1 5 4
0

Output

1

Sign in or join free to run and submit your solution.