#include <bits/stdc++.h>
using namespace std;
int n, k;
long long a[100010];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long pos = 0, neg = 0, ans, cnt = 0;
  for (int i = 0; i < k; i++) {
    if (a[i] > 0)
      pos += a[i];
    else
      neg += a[i];
  }
  for (int i = 0; i < n; i++)
    if (a[i] > 0) cnt += a[i];
  cout << "#" << cnt << " " << pos << " " << neg << endl;
  ans = cnt + max(-pos, neg);
  for (int i = k; i < n; i++) {
    if (a[i] > 0)
      pos += a[i];
    else
      neg += a[i];
    if (a[i - k] > 0)
      pos -= a[i - k];
    else
      neg -= a[i - k];
    ans = max(ans, cnt + max(-pos, neg));
  }
  cout << ans << endl;
  return 0;
}
