#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000007;
static const int INF = ((1 << 30) - 1);
static const int64_t LINF = ((1LL << 62) - 1);
struct Comb {
  vector<vector<int64_t> > data;
  Comb(int n) {
    data = vector<vector<int64_t> >(n + 1, vector<int64_t>(n + 1, 1));
    for (register int i = (1); i <= ((int)n); i++) {
      for (register int j = (0); j <= ((int)(i + 1) - 1); j++) {
        if (!j || j == i)
          data[i][j] = 1;
        else
          data[i][j] = data[i - 1][j - 1] + data[i - 1][j];
      }
    }
  }
  int64_t ncr(int n, int r) { return data[n][r]; }
};
static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}
int main() {
  int n = ri();
  int k = ri();
  int a[n];
  for (register int i = (0); i <= ((int)((sizeof(a) / sizeof(*a))) - 1); i++)
    cin >> a[i];
  int64_t s[n];
  for (register int i = (0); i <= ((int)(n)-1); i++)
    s[i] = i ? s[i - 1] + a[i] : a[i];
  int64_t ss[n];
  for (register int i = (0); i <= ((int)(n)-1); i++)
    ss[i] = i ? ss[i - 1] + (a[i] < 0 ? 0 : a[i]) : (a[i] < 0 ? 0 : a[i]);
  int64_t res = -LINF;
  for (register int i = (0); i <= ((int)(n)-1); i++) {
    if (i + k > n) break;
    int64_t base = max((int64_t)0, s[i + k - 1] - s[i - 1]);
    if (i) base += ss[i - 1];
    base += ss[n - 1] - ss[i + k - 1];
    res = max(res, base);
  }
  cout << res << endl;
  return 0;
}
