//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define int long long

#define pb push_back

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

const int maxn=100100;

int n,k;

int a[maxn];

int p[maxn];
int q[maxn];

int ans;

int32_t main()
{
  ios::sync_with_stdio(0);cin.tie(0);

  cin>>n>>k;

  for(int i=1;i<=n;i++)
    cin>>a[i];
  for(int i=1;i<=n;i++)
    p[i]=p[i-1]+a[i],
    q[i]=q[i-1]+max(a[i],0ll);
  
  for(int i=k;i<=n;i++)
    ans=max(ans,q[n]-q[i]+q[i-k]+max(p[i]-p[i-k],0ll));

  cout<<ans<<endl;
  
  return 0;
}
