n,k=map(int,input().split())
a=[]
for i in range(n):
    a.append(int(input()))

count=0

for i in range(0,n-1):
    for j in range(i+1,n-1):
        if j==n-1:
            break
        elif abs(a[i]-a[j])<=k:
            count+=1
            break

print(count)