#include <bits/stdc++.h>
using namespace std;
long long cl(long long a, long long b) { return (a + b - 1) / b; }
long long max_div[1000001];
vector<long long> prs;
void sieve() {
  for (long long i = 2; i <= 1000000; i++) {
    if (!max_div[i]) {
      for (long long j = i; j <= 1000000; j += i) {
        max_div[j] = i;
      }
    }
  }
  for (long long i = 2; i < 1000001; i++) {
    if (max_div[i] == i) prs.push_back(i);
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long K = 2 * k;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] > k) {
      if (a[i] % K > k) {
        ans += cl(a[i], K);
        a[i] = 0;
      } else {
        ans += (a[i] - a[i] % K) / K;
        a[i] %= K;
      }
    }
  }
  long long c = 0;
  for (long long i = 0; i < n; i++) {
    c += (a[i] > 0);
  }
  ans += cl(c, 2);
  cout << ans << endl;
}
int32_t main() {
  sieve();
  long long t = 1;
  for (long long i = 0; i < t; i++) solve();
  return 0;
}
