#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i;
  long long sum1 = 0;
  cin >> n >> k;
  vector<long long> arr(n);
  vector<long long> sum(n);
  vector<long long> rsum(n);
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < k; i++) {
    sum1 += arr[i];
  }
  if (arr[0] >= 0)
    sum[0] = arr[0];
  else
    sum[0] = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] >= 0)
      sum[i] = sum[i - 1] + arr[i];
    else
      sum[i] = sum[i - 1];
  }
  if (arr[n - 1] >= 0)
    rsum[n - 1] = arr[n - 1];
  else
    rsum[n - 1] = 0;
  for (i = n - 2; i >= 0; i--) {
    if (arr[i] >= 0)
      rsum[i] = rsum[i + 1] + arr[i];
    else
      rsum[i] = rsum[i + 1];
  }
  long long start = 0, end = k;
  long long temp1 = 0;
  long long ans = 0;
  for (i = 0; i < (n - k); i++) {
    ans = max(max(ans, (sum1 + temp1 + rsum[end])), temp1 + rsum[end]);
    sum1 -= arr[start];
    sum1 += arr[end];
    temp1 = sum[start];
    start++;
    end++;
  }
  cout << ans << endl;
  return 0;
}
