#include <bits/stdc++.h>
using namespace std;
int64_t mod = 1e9 + 7;
int64_t INF = 1e9 + 18;
int main() {
  ios::sync_with_stdio(false);
  int64_t n, k;
  cin >> n >> k;
  vector<int64_t> a(n);
  vector<int64_t> b(n);
  for (int64_t i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (int64_t i = 0; i < n - 1; i++) b[i + 1] += b[i];
  int64_t sum = 0;
  int64_t index = -1;
  for (int64_t i = 0; i < n - k; i++) {
    if (sum < b[i + k] - b[i]) {
      sum = b[i + k] - b[i];
      index = i;
    }
  }
  int64_t res = sum;
  for (int64_t i = 0; i < n; i++) {
    if (i == index) {
      i += k;
      continue;
    }
    if (a[i] > 0) res += a[i];
  }
  cout << (res) << '\n';
  ;
  return 0;
}
