#include <bits/stdc++.h>   using namespace std;   template <typename T>   void printArray(T arr, int l) {     for (int i = 0; i < l; i++) cout << arr[i] <<    ;     cout << endl;   }   int main(void) {     int n, k;     cin >> n >> k;     vector<int> floors;     for (int i = 0; i < n; i++) {       int temp;       cin >> temp;       floors.push_back(temp);     }     sort(floors.begin(), floors.end(), greater<int>());     int done = 0;     long long int cost = 0;     while (done < n) {       cost += 2 * (floors[done] - 1);       done += k;     }     cout << cost << endl;     return 0;   }   