#include <bits/stdc++.h>
using namespace std;
long long a[100000];
signed main(void) {
  int i, j;
  for (int testcase = 0; testcase >= 0; testcase++) {
    int n, k;
    scanf("%d%d", &n, &k);
    for (i = 0; i < n; ++i) scanf("%lld", a + i);
    int maid = 0;
    long long sum = 0LL;
    for (i = 0; i < k; ++i) sum += a[i];
    long long res = 0;
    res = max(res, sum);
    for (i = 0; i < n - k; ++i) {
      sum += a[i + k] - a[i];
      if (res < sum) {
        res = max(res, sum);
        maid = i + 1;
      }
    }
    long long tmp = 0;
    for (i = 0; i < n; ++i)
      if (a[i] >= 0) {
        if (maid <= i && i < maid + k) continue;
        tmp += a[i];
      }
    cout << (tmp + res) << "\n";
    break;
  }
  return 0;
}
