#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
int N,K;
int a[100001];
ll s[100001],s2[100001];
ll Max=-1e14;
int main(){
  cin >> N >> K;
  for(int i=1;i<=N;i++) cin >> a[i];
  for(int i=1;i<=N;i++){
    s[i]=s[i-1]+a[i];
    s2[i]=s2[i-1];
    if(a[i]>=0)s2[i]+=a[i];
  }
  for(int i=K ;i<=N;i++){
     ll x,y;
    x=s[i]-s[i-K];
    y=s2[i]-s2[i-K];
    if(x<0)x=0;
    x+=(s2[N]-y);
    Max=max(Max,x);
  }
  cout << Max << endl;
  return 0;
}
