#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int N = 100010;
const long long INF = 1e15;
long long ans;
int n, k, a[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = (1), _endtmp = (n); i <= (_endtmp); i++) scanf("%d", a + i);
  long long cur = 0;
  for (int i = (1), _endtmp = (k); i <= (_endtmp); i++) cur += 1LL * a[i];
  long long lef = 0, ri = 0;
  for (int i = (k + 1), _endtmp = (n); i <= (_endtmp); i++)
    if (a[i] > 0) ri += 1LL * a[i];
  for (int st = (1), _endtmp = (n - k + 1); st <= (_endtmp); st++) {
    chkmax(ans, lef + ri);
    if (cur > 0) chkmax(ans, lef + ri + cur);
    if (a[st] > 0) lef += a[st];
    if (st + k <= n && a[st + k] > 0) ri -= a[st + k];
  }
  cout << ans << endl;
  return 0;
}
