#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int test = 1;
  for (int loop = 0; loop < test; loop++) {
    long long int num, val;
    cin >> num >> val;
    vector<long long int> arr;
    long long int temp;
    for (int i = 0; i < num; i++) {
      cin >> temp;
      arr.push_back(temp);
    }
    long long int count = 0;
    for (int i = 0; i < num; i++) {
      for (int j = 0; j < num; j++) {
        if (abs(arr[i] - arr[j]) <= val && i != j) count++;
      }
    }
    cout << count << "\n";
  }
}
