#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

using ll = long long;

int N, K;
ll a[MAX_N];
ll S[MAX_N+1], zS[MAX_N+1];

int main()
{
  scanf( "%d%d", &N, &K );
  rep( i, N )
    scanf( "%lld", a+i );
  S[0] = 0;
  zS[0] = 0;
  rep( i, N )
  {
    S[i+1] = S[i]+a[i];

    zS[i+1] = zS[i]+std::max( 0ll, a[i] );
  }

  ll ans = 0;
  rep( i, N-K+1 )
    ans = std::max( ans, std::max( 0ll, S[i+K]-S[i] )+zS[i]-zS[0]+zS[N]-zS[i+K] );

  printf( "%lld\n", ans );

  return 0;
}