#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  long long int sum = 0;
  int pos = 0, now = 0, minv = 0;
  for (int i = 0; i < (n); ++i) cin >> v[i];
  for (int i = 0; i < (k); ++i) now += v[i];
  minv = now;
  for (int i = k; i < n; i++) {
    now += v[i] - v[i - k];
    if (abs(minv) < abs(now)) {
      minv = now;
      pos = i - k + 1;
    }
  }
  for (int i = 0; i < pos; i++) {
    if (v[i] > 0) sum += v[i];
  }
  for (int i = pos + k; i < n; i++) {
    if (v[i] > 0) sum += v[i];
  }
  cout << sum + max(0, minv) << endl;
  return 0;
}
