#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
  int n, k;
  vector<int> a(n);
  cin >> n >> k;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> a[i];
  }
  vector<long long> sum(n, a[0]), best_sum(n, max(0, a[0]));
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
    best_sum[i] = best_sum[i - 1] + max(0, a[i]);
  }
  long long ans = -1e9;
  for (int i = 0; i + k <= n; i++) {
    long long tmp = 0, plus = 0;
    if (i == 0) {
      tmp = max(0LL, sum[k - 1]);
      plus = best_sum[n - 1] - best_sum[k - 1];
    } else {
      tmp = max(0LL, sum[i + k - 1] - sum[i - 1]);
      plus = best_sum[n - 1] - (best_sum[i + k - 1] - best_sum[i - 1]);
    }
    long long score = tmp + plus;
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}
