#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<algorithm>
#define ll long long
using namespace std;
ll a[100005],ans;
ll n,k;
struct node{
ll x,y;
};
struct cmp{
bool operator () (const node &x,const node &y) const
{
return x.x>y.x;
}
};
priority_queue<node,vector<node>,cmp>q;
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
q.push({a[i],0});
}
ll pos=(n-1)%(k-1);
if(pos!=0){
ll cnt=0,maxx=0;
for(int i=1;i<=pos+1;i++){
cnt+=q.top().x;
maxx=max(maxx,q.top().y);
q.pop();
}
q.push({cnt,maxx+1});
ans+=cnt;
}
while(q.size()!=1){
ll cnt=0,maxx=0;
for(int i=1;i<=k;i++){
cnt+=q.top().x;
maxx=max(maxx,q.top().y);
q.pop();
}
q.push({cnt,maxx+1});
ans+=cnt;
}
cout<<ans<<endl<<q.top().y;
return 0;
}