#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  vector<long long> t(n);
  for (int i = 0; i < n; i++) scanf("%lld", &t[i]);
  long long sum = 0;
  for (int i = 0; i < k; i++) sum += t[i];
  long long summ = sum;
  long long ind = 0;
  long long zero = 0ll;
  for (int i = k; i < n; i++) {
    sum += t[i] - t[i - k];
    if (sum > summ) {
      summ = sum;
      ind = i - k + 1;
    }
  }
  long long sump = summ;
  for (int i = 0; i < n; i++)
    if (i < ind || i >= ind + k) sump += max(zero, t[i]);
  cout << max(zero, sump) << endl;
}
