#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N,K;
  cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int nn=0;
  int c;
  int o=0;
  for(int i=0;i<N;i++)nn+=max(o,v[i]);
  int m;
  c=0;
  for(int i=0;i<K;i++)c+=min(o,v[i]);
  m=c;
  for(int i=0;i<N-K;i++){
    c+=min(o,v[i+K])-min(o,v[i]);
    m=max(m,c);
  }
  int ans=nn+m;
  c=0;
  for(int i=0;i<K;i++)c+=max(o,v[i]);
  m=c;
  for(int i=0;i<N-K;i++){
    c+=max(o,v[i+K])-max(o,v[i]);
    m=min(m,c);
  }
  ans=max(ans,nn-m);
  cout<<ans<<endl;
}
