#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  vector<int> A;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    A.push_back(temp);
  }
  sort(A.rbegin(), A.rend());
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) ans += (A[i] - A[i + 1]);
  for (int i = k - 1; i < n - 1; i += k) ans -= (A[i] - A[i + 1]);
  for (int i = 0; i < n; i += k) {
    if (i <= (n - k))
      ans += (A[i] + A[i + k - 1] - 2);
    else
      ans += (A[i] + A[n - 1] - 2);
  }
  cout << ans << endl;
}
