In this challenge, you will be given an array of integers, each unique within the array, and an integer representing a target difference. You must determine the number of pairs of elements in the array that have a difference equal to the target difference.

 

For example, consider the array [1, 3, 5] and a target difference 2. There are two pairs: [1,3] and [3,5], that have the target difference.

 

Function Description 

Complete the function kDifference in the editor below. The function must return an integer count of the number of pairs within a having a difference of k.

 

kDifference has the following parameter(s):

    a[a[0],...a[n-1]]:  array of integers to test

    k: the target difference

 

Constraints

5 ≤ n ≤ 105
Each element of a, a[i] ≤ 2 × 109.
Each a[i] is unique within a.
1 ≤ k ≤ 109
 

Input Format for Custom Testing
Input from stdin will be processed as follows and passed to the function.

 

The first line contains an integer n, the size of the array a.

The next n lines each contain an element a[i] where 0 ≤ i < n.

The next line contains the integer k, the target difference.

Sample Case 0
Sample Input 0



5
1
5
3
4
2
2
 

Sample Output 0

3
 

Explanation 0

We must count the number of pairs in a = [1, 5, 3, 4, 2] whose difference is k = 2. We find the following three pairs: (1, 3), (5, 3), and (4, 2).

 

Sample Case 1
Sample Input 1

10
363374326
364147530
61825163
107306571
128124602
139946991
428047635
491595254
879792181
106926279
1
 

Sample Output 1

0
 

Explanation 1

We must count the number of pairs in a = [363374326, 364147530, 61825163, 107306571, 1281246024, 139946991, 428047635, 491595254, 879792181, 106926279] whose difference is k = 1. Because no such pair of integers exists in a, we return 0.

 

Sample Case 2
Sample Input 2

6
2
4
6
8
10
12
2
 

Sample Output 2

5
 

Explanation 2

c312720057b6816d8659291860f1b7ce364ae7a4
In this challenge, you will be given an array of integers, each unique within the array, and an integer representing a target difference. You must determine the number of pairs of elements in the array that have a difference equal to the target difference.

 

For example, consider the array [1, 3, 5] and a target difference 2. There are two pairs: [1,3] and [3,5], that have the target difference.

 

Function Description 

Complete the function kDifference in the editor below. The function must return an integer count of the number of pairs within a having a difference of k.

 

kDifference has the following parameter(s):

    a[a[0],...a[n-1]]:  array of integers to test

    k: the target difference

 

Constraints

5 ≤ n ≤ 105
Each element of a, a[i] ≤ 2 × 109.
Each a[i] is unique within a.
1 ≤ k ≤ 109
 

Input Format for Custom Testing
Input from stdin will be processed as follows and passed to the function.

 

The first line contains an integer n, the size of the array a.

The next n lines each contain an element a[i] where 0 ≤ i < n.

The next line contains the integer k, the target difference.

Sample Case 0
Sample Input 0



5
1
5
3
4
2
2
 

Sample Output 0

3
 

Explanation 0

We must count the number of pairs in a = [1, 5, 3, 4, 2] whose difference is k = 2. We find the following three pairs: (1, 3), (5, 3), and (4, 2).

 

Sample Case 1
Sample Input 1

10
363374326
364147530
61825163
107306571
128124602
139946991
428047635
491595254
879792181
106926279
1
 

Sample Output 1

0
 

Explanation 1

We must count the number of pairs in a = [363374326, 364147530, 61825163, 107306571, 1281246024, 139946991, 428047635, 491595254, 879792181, 106926279] whose difference is k = 1. Because no such pair of integers exists in a, we return 0.

 

Sample Case 2
Sample Input 2

6
2
4
6
8
10
12
2
 

Sample Output 2

5
 

Explanation 2
