uses math;
const maxn = 10000;
fi = '';
fo = '';
var n:word;
k:byte;
a: array[1..maxn] of integer;
f: array[0..maxn] of longint;
res:longint;
procedure enter;
var i,j:word;
begin
assign(input,fi);
reset(input);
assign(output,fo);
rewrite(output);
readln(n,k);
f[0]:=0;
res:=0;
for i:=1 to n do
begin
read(a[i]);
f[i]:=trunc(-10e9);
if i=1 then f[i]:=max(0,a[i])
else
for j:=i-1 downto max(0,i-k) do
f[i]:=max(f[i],f[j]+a[i]);
if f[i]>res then res:=f[i];
end;
writeln(res);
close(input);
close(output);
end;
begin
enter;
end.
dXNlcyBtYXRoOwpjb25zdCBtYXhuID0gMTAwMDA7CiAgICAgIGZpID0gJyc7CiAgICAgIGZvID0gJyc7CnZhciBuOndvcmQ7CiAgICBrOmJ5dGU7CiAgICBhOiBhcnJheVsxLi5tYXhuXSBvZiBpbnRlZ2VyOwogICAgZjogYXJyYXlbMC4ubWF4bl0gb2YgbG9uZ2ludDsKICAgIHJlczpsb25naW50Owpwcm9jZWR1cmUgZW50ZXI7CnZhciBpLGo6d29yZDsKYmVnaW4KICBhc3NpZ24oaW5wdXQsZmkpOwogIHJlc2V0KGlucHV0KTsKICBhc3NpZ24ob3V0cHV0LGZvKTsKICByZXdyaXRlKG91dHB1dCk7CiAgcmVhZGxuKG4sayk7CiAgZlswXTo9MDsKICByZXM6PTA7CiAgZm9yIGk6PTEgdG8gbiBkbwogIGJlZ2luCiAgICByZWFkKGFbaV0pOwogICAgZltpXTo9dHJ1bmMoLTEwZTkpOwogICAgaWYgaT0xIHRoZW4gZltpXTo9bWF4KDAsYVtpXSkKICAgIGVsc2UKICAgICAgZm9yIGo6PWktMSBkb3dudG8gbWF4KDAsaS1rKSBkbwogICAgICBmW2ldOj1tYXgoZltpXSxmW2pdK2FbaV0pOwogICAgaWYgZltpXT5yZXMgdGhlbiByZXM6PWZbaV07CiAgZW5kOwogIHdyaXRlbG4ocmVzKTsKICBjbG9zZShpbnB1dCk7CiAgY2xvc2Uob3V0cHV0KTsKZW5kOwpiZWdpbgogIGVudGVyOwplbmQu