//Noi2015 epic
#include <iostream>
#include <queue>
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
long long readint()
{
long long ans=0;
char c;
while (!isdigit(c=getchar()));
do
{
ans=ans*10+c-'0';
c=getchar();
} while (isdigit(c));
return ans;
}
struct Node
{
long long w,h;
Node(long long w,long long h):w(w),h(h){}
};
bool operator <(Node a,Node b)
{
if (a.w<b.w)
return false;
if (a.w>b.w)
return true;
return (a.h>b.h);
}
priority_queue<Node> ans;
int main()
{
freopen("epic.in","r",stdin);
freopen("epic.out","w",stdout);
long long n=readint();
long long k=readint();
for (long long i=0;i<n;i++)
ans.push(Node(readint(),0));
if ((n-1)%(k-1))
for (long long i=0;i<(k-1)-(n-1)%(k-1);i++)
ans.push(Node(0,0));
long long sum=0,hm=0;
while (ans.size()>1)
{
long long hi=0,s=0;
for (long long i=0;i<k;i++)
{
Node ls=ans.top();
s+=ls.w;
hi=max(hi,ls.h);
ans.pop();
}
ans.push(Node(s,hi+1));
sum+=s;
hm=max(hm,hi+1);
}
cout<<sum<<endl;
cout<<hm<<endl;
return 0;
}