#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int n{0};
  int diff{0};
  cin >> n >> diff;
  vector<int> values;
  int count{0};
  int x{0};
  for (int i = 0; i < n; i++) {
    cin >> x;
    values.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int a = values[i];
    for (int j = i + 1; j < n; j++) {
      if (abs(a - values[j]) <= diff) {
        count += 2;
      }
    }
  }
  cout << count << endl;
  return 0;
}
