#include<stdio.h>
int main()
{
int a[110],m,n,i,j,k,q,min=100000,max=0;
freopen("waterj.in","r",stdin);
freopen("waterj.out","w",stdout);
scanf("%d%d",&n,&m);
for (i=0;i<m;i++)
scanf("%d",&a[i]);
for (i=m;i<n;i++)
{
scanf("%d",&k);
for (j=0;j<m;j++)
if (min>a[j]) {min=a[j];q=j;}
min=100000;
a[q]+=k;
}
for (i=0;i<m;i++)
if (max<a[i]) max=a[i];
printf("%d",max);
fclose (stdin);
fclose (stdout);
return 0;
}