#include <iostream>
#include <cstring>
#include <algorithm>

#define MAX_N  100000

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;
//入力
int K;
int N;
int a[MAX_N + 1];

typedef long long ll;


int main() {

  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }


  ll cumsum[MAX_N + 1];
  ll cumsum_pos[MAX_N + 1];
  cumsum[0] = 0;
  cumsum_pos[0] = 0;
  for(int i = 1; i <= N; i++) {
    cumsum[i] = cumsum[i-1] + a[i-1];
    cumsum_pos[i] = cumsum_pos[i-1] + max(0, a[i-1]);
  }

  ll mx = 0;
  for(int i = 0; i <= N - K; i++) {

    ll black = cumsum[i+K] - cumsum[i];
    ll white = 0;

    ll other = (cumsum_pos[N-k] - cumsum_pos[i+K-1]) + cumsum_pos[i-1];

    mx = max(mx, other + max(black, white));

  }

  cout << mx << endl;

  return 0;

}
