#include <bits/stdc++.h>
using namespace std;
long long a[100001], he[100001], xsum, sum;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] >= 0) he[i] = a[i] + he[i - 1];
  }
  for (int i = 1; i <= n - k + 1; i++) {
    for (int j = i; j <= i + k - 1; j++) {
      xsum += a[j];
    }
    if (xsum > 0)
      xsum = he[i - 1] + he[n] - he[i + k - 1] + xsum;
    else
      xsum = he[i - 1] + he[n] - he[i + k - 1];
    sum = max(xsum, sum);
  }
  cout << sum;
  return 0;
}
