#include<bits/stdc++.h>
using namespace std;
int f[10002];
int i,j,n,m;
int a[10002];
int s[10002];
int main()
{
freopen("cowrun.in","r",stdin);
freopen("cowrun.out","w",stdout);
scanf("%d%d",&n,&m);
for (i=1;i<=n;i++){
scanf("%d",&a[i]);
s[i]=s[i-1]+a[i];
}
for (i=1;i<=n;i++){
f[i]=f[i-1];
for (int j=1;j<=m&&j+j<=i;j++)
if (f[i-2*j]+s[i-j]-s[i-2*j]>f[i])
f[i]=f[i-2*j]+s[i-j]-s[i-2*j];
}
printf("%d",f[n]);
return 0;
}