#include <bits/stdc++.h>
using namespace std;
long long sum[100100];
vector<int> a;
long long solve(vector<int> a, int n, int k) {
  long long res = 0;
  long long cur = 0;
  for (int i = (0); i < (n); ++i) {
    sum[i] = 0;
    if ((i >= n - k) || (a[i] > 0)) {
      sum[i] = a[i];
      cur += a[i];
    }
    if (i) {
      sum[i] += sum[i - 1];
    }
  }
  res = max(res, cur);
  for (int i = n - 1; i >= n - k; --i) {
    long long delSum = sum[i];
    if (i - k >= 0) {
      delSum -= sum[i - k];
    }
    res = max(res, cur - delSum);
  }
  return res;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  a.resize(n);
  for (int i = (0); i < (n); ++i) {
    scanf("%d", &a[i]);
  }
  long long res = 0;
  res = max(res, solve(a, n, k));
  reverse(a.begin(), a.end());
  res = max(res, solve(a, n, k));
  cout << res << endl;
  return 0;
}
