#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int arr[1005], d, cnt = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (abs(arr[i] - arr[j]) <= d)
        cnt++;
      else
        break;
    }
  }
  cout << cnt * 2 << endl;
}
