#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-14;
const double PI = acos(-1.0);
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<long long> v(n);
  for (int i = (int)(0); i < (int)(n); i++) {
    scanf("%lld", &v[i]);
  }
  vector<pair<long long, int> > w;
  w.push_back(make_pair(accumulate(v.begin(), v.begin() + k, 0), 0));
  for (int i = (int)(1); i < (int)(n - k + 1); i++) {
    w.push_back(make_pair(w[i - 1].first - v[i - 1] + v[i - 1 + k], i));
  }
  sort(w.begin(), w.end(), greater<pair<long long, int> >());
  long long sum1 = w[0].first;
  for (int i = (int)(0); i < (int)(n); i++) {
    if (w[0].second <= i && i < w[0].second + k)
      continue;
    else
      sum1 += max(v[i], (long long)0);
  }
  long long sum2 = 0;
  for (int i = (int)(0); i < (int)(n); i++) {
    if (w[n - k].second <= i && i < w[n - k].second + k)
      continue;
    else
      sum2 += max(v[i], (long long)0);
  }
  cout << max(sum1, sum2) << endl;
}
