program df;
var
f1,f2:text;
a,f:array[0..100000]of longint;
max,min,n,m,i,j:longint;
procedure main(q,l:longint);
var
i,o:longint;
begin
if q>m-1 then begin
if f[n]-f[l-1]>max then max:=f[n]-f[l-1];
if max<min then min:=max end
else begin
for i:= l to n-m+q do begin
o:=max;
if f[i]-f[l-1]>max then max:=f[i]-f[l-1];
main(q+1,i+1);
max:=o;
end;
end;
end;
begin
assign(f1,'expense.in');
assign(f2,'expense.out');
reset(f1);
rewrite(f2);
readln(f1,n,m);
f[0]:=0;
for i:= 1to n do begin readln(f1,a[i]);f[i]:=f[i-1]+a[i];end;
min:=f[n];max:=-1;f[0]:=0;a[0]:=0;
main(0,0);
writeln(f2,min);
close(f1);
close(f2);
end.