#include <bits/stdc++.h>
const long long int mod = 1000000007;
const double pi = acos(-1.0);
using namespace std;
int main() {
  priority_queue<long long int> mypq;
  long long int n;
  long long int k;
  cin >> n;
  cin >> k;
  long long int count;
  count = 0;
  for (long long int i = (long long int)0; i < (long long int)n; ++i) {
    long long int x;
    cin >> x;
    if (x >= 2 * k) {
      long long int y;
      y = x / (2 * k);
      count += y;
    }
    if (x % (2 * k) != 0) mypq.push(x % (2 * k));
  }
  while (!mypq.empty()) {
    if (mypq.top() > k) {
      long long int x;
      x = mypq.top();
      mypq.pop();
      x = x - k;
      mypq.push(x);
    } else {
      long long int x;
      x = mypq.top();
      mypq.pop();
    }
    if (mypq.top() > k && !mypq.empty()) {
      long long int x;
      x = mypq.top();
      mypq.pop();
      x = x - k;
      mypq.push(x);
    } else if (!mypq.empty()) {
      mypq.pop();
    }
    count++;
  }
  cout << count << endl;
  return 0;
}
