#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1LL<<60);

ll N,K;
ll a[100005];
ll b[100005];

int main(){
  cin>>N>>K;
  for(int i=1;i<=N;i++){
    cin>>a[i];
    if(a[i]>0)b[i]=a[i];
  }
  for(int i=0;i<=N;i++){
    a[i+1]+=a[i];
    b[i+1]+=b[i];
  }
  ll ans=-INF;
  for(int i=0;i+K<=N;i++){
    ll first = max( a[i+K]-a[i], 0LL);
    ll second = b[i] + ( b[N]-b[i+K] );
    ans=max(ans,first+second);
  }
  cout<<ans<<endl;
  return 0;
}
