#include <bits/stdc++.h>
using namespace std;
long long int N, K, l, i, d[100000], b;
vector<long long int> a, p;
int main() {
  scanf("%lld%lld", &N, &K);
  for (i = 0; i < N; ++i) {
    scanf("%lld", &l);
    a.push_back(l);
    if (l > 0) {
      b += l;
    }
    p.push_back(b);
  }
  partial_sum(a.begin(), a.end(), a.begin());
  for (i = 0; i <= N - K; ++i) {
    d[i] = (i > 0 ? p[i - 1] : 0) + max(a[i + K - 1] - a[i - 1], 0LL) +
           ((i + K < N) ? b - p[i + K - 1] : 0);
  }
  cout << *max_element(d, d + N) << endl;
  return 0;
}
