#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, m, sum;
long long a[100000];
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i] = read() - 1;
  sort(a + 1, a + n + 1);
  while (n % m != 0) {
    a[++n] = a[1];
  }
  sort(a + 1, a + n + 1);
  for (int i = m; i <= n; i += m) sum += 2 * a[i];
  printf("%lld\n", sum);
}
