#include <bits/stdc++.h>
using namespace std;
const int HUGEI = 2147483647;
const long long HUGEL = 9223372036854775807;
const string ABC = "abcdefghijklmnopqrstuvwxyz";
int main(void) {
  int n, k;
  vector<int> an;
  vector<int> sum_all, sum_positive;
  cin >> n >> k;
  sum_all.push_back(0);
  sum_positive.push_back(0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    an.push_back(a);
    sum_all.push_back(sum_all.back() + a);
    sum_positive.push_back(sum_positive.back() + max(a, 0));
  }
  int res = 0;
  for (int i = 0; i < n - k; i++) {
    int re;
    re = sum_positive[i + 1] + sum_positive[n] - sum_positive[i + k + 1];
    re += max(0, sum_all[i + k + 1] - sum_all[i + 1]);
    res = max(re, res);
  }
  cout << res << endl;
  return 0;
}
