#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

template<class T>
ll part(const T& s,int l, int r){return s[r] - s[l];};

ll a[100050],s[100050],p[100050];

int main(){
  int N,K; cin>>N>>K;
  for(int i=0;i<N;i++) cin>>a[i];
  for(int i=0;i<N;i++) s[i+1] = s[i] + a[i];
  for(int i=0;i<N;i++) {
    if(a[i] > 0) p[i+1] = p[i] + a[i];
    else p[i+1] = p[i];
  }
  ll ans = 0;
  for(int i=0;i+K<=N;i++){
    ll tmp = part(p,0,i) + part(p,i+K,N);
    ll b = part(s,i,i+K);
    if(b > 0) tmp += b;
    if(ans < tmp) ans = tmp;
  }
  cout<<ans<<endl;
  return 0;
}
