#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
long long big = 1000000007ll;
long long n, m, k, r;
long long nt;
long long T;
vector<long long> CSP;
vector<long long> CS;
vector<long long> A;
int main() {
  int c1, c2, c3, c4, c5, c6;
  long long a, b, c, e;
  cin >> n >> k;
  CS.push_back(0);
  CSP.push_back(0);
  for (c1 = 0; c1 < n; c1++) {
    cin >> a;
    A.push_back(a);
    CS.push_back(a + CS[c1]);
    CSP.push_back(CSP[c1] + a * (a > 0));
  }
  long long ans = 0;
  for (c1 = 0; c1 < n - k; c1++) {
    long long bos = max(CS[c1 + k] - CS[c1], 0ll);
    ans = bos + max(ans, CSP[n] - (CSP[c1 + k] - CSP[c1]));
  }
  cout << ans << "\n";
  return 0;
}
