/*
MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
http://www.cnblog.com/MiYu
Author By : MiYu
Test : 1
Program : 3450
*/
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 100010;
const int MOD = 9901;
int nCount = 0;
int com[MAX];
int hash[MAX];
int num1[MAX];
int num2[MAX];
int N,D;
inline int low ( int x ) {
return x & ( -x );
}
void modify ( int x, int val ){ // 修改
while ( x <= nCount ){
com[x] += val; x += low ( x );
}
}
int quy ( int x ){ // 查询
int sum = 0;
while ( x > 0 ){
sum += com[x]; x -= low ( x );
}
return sum ;
}
int find1 ( int val ){ // 二分 找 <= val 的第一个数
int beg = 1, end = nCount; int mid = ( beg + end ) >> 1; int res = mid;
while ( beg <= end ){
if ( hash[mid] <= val ){
beg = mid + 1; res = mid;
}else{
end = mid - 1;
}
mid = ( beg + end ) >> 1;
}
return res;
}
int find2 ( int val ){ // 二分 找 <= val 的第一个数
int beg = 1, end = nCount; int mid = ( beg + end ) >> 1; int res = mid;
while ( beg <= end ){
if ( hash[mid] < val ){
beg = mid + 1;
}else{
end = mid - 1; res = mid;
}
mid = ( beg + end ) >> 1;
}
return res;
}
inline bool scan_d(int &num) // 输入
{
char in;bool IsN=false;
in=getchar();
if(in==EOF) return false;
while(in!='-'&&(in<'0'||in>'9')) in=getchar();
if(in=='-'){ IsN=true;num=0;}
else num=in-'0';
while(in=getchar(),in>='0'&&in<='9'){
num*=10,num+=in-'0';
}
if(IsN) num=-num;
return true;
}
int main ()
{
while ( scan_d ( N ) && scan_d ( D ) ){
for ( int i = 0; i < N; ++ i ){
scan_d ( num1[i] ); num2[i] = num1[i];
}
sort ( num1, num1 + N );
hash[1] = num1[0]; nCount = 1;
for ( int i = 1; i < N; ++ i ){ // 数据 离散化
if ( num1[i] != num1[i-1] ) hash[++nCount] = num1[i];
}
memset ( com, 0, sizeof ( com ) );
for ( int i = 0; i < N; ++ i ){
int pos = find1 ( num2[i] ); // 找当前元素的 hash 下标
int pre = find1 ( num2[i] + D ); // 找 <= num2[i] + D 的第一个数
int tail = find2 ( num2[i] - D ); // 找 >= num2[i] - D 的第一个数
int val = quy ( pre ) - quy ( tail - 1 ) + 1; // 区间 [ num2[i] - D, num2[i] + D ] 的元素个数 + 新增的一个元素
modify ( pos, val % MOD );
}
cout << ( quy ( nCount ) - N ) % MOD << endl; //以 一个元素 的 [ elem - D, elem + D ] 计算, 题目要求 k >= 2, 减掉 N 个
}
return 0;
}