import std.stdio;

int main(string[] args){
int n,k,max=0;
int val[5004];
int sumArray[5004];


scanf("%d %d",&n,&k);

for(int i=0;i<n;i++){
scanf("%d",&val[i]);
if(i == 0)sumArray[i]=val[i];
else sumArray[i]=sumArray[i-1]+val[i];
}

max = sumArray[2];
for(int i=3;i<n;i++){
if(sumArray[i]-sumArray[i-3] > max)max=sumArray[i]-sumArray[i-3];
}

writeln(max);
return 0;
}