#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<algorithm>#include<vector>#include<queue>usingnamespace std;typedeflonglong ll;typedef pair<ll, ll> PLL;constint N =1e5+10;
ll n, k;
ll w[N];intmain(){
cin >> n >> k;
priority_queue<PLL, vector<PLL>, greater<PLL>> heap;for(int i =1; i <= n; i++){
cin >> w[i];
heap.push({
w[i],0});}while((n -1)%(k -1)){
heap.push({
0ll,0});
n++;}
ll res =0;while(heap.size()>1){
ll s =0;
ll h =0;for(int i =1; i <= k; i++){
auto x = heap.top();
heap.pop();
s += x.first;
h =max(h, x.second);}
res += s;
heap.push({
s, h +1});}
cout << res <<"\n"<< heap.top().second << endl;return0;}