45pts damn____
#include<bits/stdc++.h>
#define Max 100001
using namespace std;
int read(){
char ch=getchar();
int x=0,f=1;
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+(ch^48);
ch=getchar();
}
return x*f;
}
struct node{
long long sum;
int depth;
friend bool operator<(node a,node b){
if(a.sum!=b.sum)return a.sum>b.sum;
else return a.depth>b.depth;
}
};
long long ans,msum=0;
priority_queue<node> p;
int main(){
int n,k,a,s,mdepth=0;n=read(),k=read();
s=(n-1)/(k-1)+1;
for(int i=1;i<=n;i++){
a=read();
p.push({a,0});
}
if((n-1)%(k-1)!=0)for(int i=1;i<=s*(k-1)+1-n;i++)p.push({0,0});
while(p.size()>=k){
msum=0;
mdepth=0;
for(int i=1;i<=k;i++){
node z=p.top();
p.pop();
msum+=z.sum;
mdepth=max(mdepth,z.depth);
}
ans+=msum;
p.push({msum,mdepth+1});
}
printf("%lld\n%lld",ans,p.top().depth);
return 0;
}