var a:array[1..11000]of longint;
min,max,n,m,i,j,k,q:longint;
begin
assign(input,'waterj.in');reset(input);
assign(output,'waterj.out');rewrite(output);
fillchar(a,sizeof(a),0);
min:=maxlongint;max:=-maxlongint;
read(n,m);
for i:=1 to m do
read(a[i]);
for i:=m to n-1 do
begin
read(k);
for j:=1 to m do
if min>a[j] then begin min:=a[j];q:=j;end;
min:=maxlongint;
inc(a[q],k);
end;
for i:=1 to m do
if max<a[i] then max:=a[i];
write(max);
close(input);close(output);
end.