According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most *d* centimeters. Captain Bob has *n* soldiers in his detachment. Their heights are *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> centimeters. Some soldiers are of the same height. Bob wants to know, how many ways exist to form a reconnaissance unit of two soldiers from his detachment.

Ways (1, 2) and (2, 1) should be regarded as different.
The first line contains two integers *n* and *d* (1 ≤ *n* ≤ 1000, 1 ≤ *d* ≤ 10<sup class="upper-index">9</sup>) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains *n* space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 10<sup class="upper-index">9</sup>.
'''
Amirhossein Alimirzaei
Telegram : @HajLorenzo
Instagram : amirhossein_alimirzaei
University of Bojnourd
'''


# Be Kasif tarin halat momken neveshtam hal kon :DDDD

N = list(map(int, input().split()))
L = sorted(list(map(int, input().split())))
C = 0
for _ in range(N[0] - 1):
    I=_+1
    while(True):
        if (L[_] <= L[I] and abs(L[_]-L[I])<=N[1]):
            C+=2
        I+=1
        if(I>=N[0]):
            break
print(C)













'''
for _ in range(N[0] - 2):
    I=_+1
    while True:
        print("in")
        print("I : ",I)
        if (L[_] <= L[I] and abs(L[_]-L[I])<=N[1]):
            if (L[_] == L[I]):
                if (ISTHERE(L[_], L)):
                    print("B1 : ", L[_])
                    LRNZ.append(L[_])
                    C += 1
            else:
                print("B2 : ", L[_])
                C += 2
        else:
            break
        I += 1
    print("LRNZ : ",LRNZ)
print(C)
'''
