#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long double EPS = 1e-8;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < (int)(N); i++) cin >> a[i];
  vector<int> b(N);
  for (int i = 0; i < (int)(N); i++) b[i] = max(0, a[i]);
  vector<int> cuma(N + 1, 0), cumb(N + 1, 0);
  for (int i = 0; i < (int)(N); i++) cuma[i + 1] = cuma[i] + a[i];
  for (int i = 0; i < (int)(N); i++) cumb[i + 1] = cumb[i] + b[i];
  long long res = 0;
  for (int i = K; i <= N; ++i) {
    long long tmp1 = cumb[i - K] + cumb[N] - cumb[i] + cuma[i] - cuma[i - K];
    long long tmp2 = cumb[i - K] + cumb[N] - cumb[i];
    res = max(res, tmp1);
    res = max(res, tmp2);
  }
  cout << res << endl;
  return 0;
}
