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

const long long INF=10000000000000000ll;
int main()
{
  int n,K;
  scanf("%d%d",&n,&K);
  static long long a[100000];
  for(int i=0;i<n;i++){
    scanf("%lld",a+i);
  }
  static long long S[100010],S2[100010];
  S[0]=S2[0]=0;
  for(int i=0;i<n;i++){
    S[i+1]=S[i]+a[i];
    S2[i+1]=S2[i]+(a[i]<0?0:a[i]);
  }
  long long ans=-INF;
  for(int i=0;i+K<=n;i++){
    ans=max(ans,S2[i]+(S[i+K]-S[i])+(S2[n]-S2[i+K]));
    ans=max(ans,S2[i]+(S2[n]-S2[i+K]));
  }
  printf("%lld\n",ans);
  return 0;
}
