#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int N, K;
ll a[100001];
ll sum_a [100001];
ll b[100001];
ll sum_b [100001];

int main() {
  cin >> N >> K;

  for(int i = 0; i < N; i++) {
    cin >> a[i];
    b[i] = max(0ll,a[i]);
  }
  for(int i = 1; i <= N; i++) {
    sum_a[i] = sum_a[i-1] + a[i-1];
    sum_b[i] = sum_b[i-1] + b[i-1];
  }

  ll ans = 0;

  for(int i = 0; i + K <= N; i++) {
    ans = max(ans,max(0LL,sum_a[i+K]-sum_a[i]) + sum_b[i] + sum_b[N] - sum_b[i+K]);
  }
  cout << ans <<endl;
}


 
