#include <bits/stdc++.h>
const int INF = 2000000000;
using namespace std;
int n, k;
long long solve(int p, long long a[100005]) {
  long long ret = 0;
  for (int i = 0; i < (n); i++) {
    if (i >= p && i < p + k) continue;
    if (a[i] > 0) ret += a[i];
  }
  return ret;
}
int main() {
  long long a[100005];
  cin >> n >> k;
  for (int i = 0; i < (n); i++) cin >> a[i];
  long long sum = 0, maxi, mini;
  int maxp = 0, minp = 0;
  for (int i = 0; i < (k); i++) sum += a[i];
  maxi = mini = sum;
  for (int i = (k); i < (n); i++) {
    sum += a[i];
    sum -= a[i - k];
    if (maxi < sum) {
      maxi = sum;
      maxp = i - k + 1;
    }
    if (mini > sum) {
      mini = sum;
      minp = i - k + 1;
    }
  }
  long long ans[2] = {0};
  ans[0] = solve(maxp, a);
  ans[0] += maxi;
  ans[1] = solve(minp, a);
  cout << max(ans[0], ans[1]) << endl;
}
