#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  vector<long long> a(n + 1), b(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] >= 0) b[i] = a[i];
  }

  for (int i = 1; i <= n; ++i) {
    a[i] += a[i - 1];
    b[i] += b[i - 1];
  }

  long long ans = 0;
  for (int i = 0; i < n - k + 1; ++i) {
    ans = max(ans, max(0ll, a[i + k] - a[i]) + b[i] - b[0] + b[n] - b[i + k]);
  }

  cout << ans << endl;
}
