#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
long long INF = 1e18;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> a(n), maxsum(n, 0), sum(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) {
      if (a[0] > 0) maxsum[0] = a[0];
      sum[0] = a[0];
    } else {
      if (a[i] > 0)
        maxsum[i] = maxsum[i - 1] + a[i];
      else
        maxsum[i] = maxsum[i - 1];
      sum[i] = sum[i - 1] + a[i];
    }
  }
  if (n == k) {
    cout << maxsum[n - 1] << endl;
    return 0;
  }
  long long ans = max(sum[k - 1] + (maxsum[n - 1] - maxsum[k - 1]),
                      (sum[n - 1] - sum[n - k - 1]) + maxsum[n - k - 1]);
  ans = max({ans, maxsum[n - 1] - maxsum[k - 1], maxsum[n - k - 1]});
  for (int i = 1; i + k < n; i++) {
    ans = max(ans, (sum[i + k - 1] - sum[i - 1]) +
                       (maxsum[n - 1] - maxsum[i + k - 1]) + (maxsum[i - 1]));
    ans = max(ans, (maxsum[n - 1] - maxsum[i + k - 1]) + (maxsum[i - 1]));
  }
  cout << ans << endl;
}
