#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<queue>
#define ll long long
using namespace std;
ll n,k,N,ans=0;
struct node{
ll pos,w,step;
friend bool operator <(node a,node b)
{
if(a.w!=b.w)return a.w>b.w;
return a.pos>b.pos;
}
};
priority_queue<node> q;
int main()
{
cin>>n>>k;
for(ll i=1;i<=n;i++)
{
int t;
cin>>t;
q.push(node{i,t,0});
}
N=n;
while((N-1)%(k-1)!=0)
{
q.push(node{++N,0,0});
}
while(q.size()>=k)
{
ll maxx=0,s=0;
for(ll i=1;i<=k;i++)
{
node t;
t=q.top();
s+=t.w;
maxx=max(maxx,t.step);
q.pop();
}
ans+=s;
q.push(node{++N,s,maxx+1});
}
cout<<ans<<endl;
cout<<q.top().step<<endl;
return 0;
}