#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
int cn[maxn];
int main() {
  int n, m, g;
  int i, j;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(cn, 0, sizeof(cn));
    for (int i = 0; i < n; i++) {
      scanf("%d", &g);
      cn[g]++;
    }
    int ans = 0;
    int use = 0;
    for (int i = maxn - 3; i >= 0; i--) {
      if (use > 0) {
        if (cn[i] > use) {
          cn[i] -= use;
          use = 0;
        } else {
          use -= cn[i];
          cn[i] = 0;
          continue;
        }
      }
      ans += cn[i] / m * (i - 1) * 2;
      cn[i] = cn[i] % m;
      if (cn[i] % m) {
        ans += (i - 1) * 2;
        use += m - cn[i];
        cn[i] = 0;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
