#include <bits/stdc++.h>
using namespace std;
vector<int> g[114514];
bool used[114514];
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<long long> s(n + 1), t(n + 1);
  s[0] = t[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
    t[i + 1] = t[i] + max((long long)0, a[i]);
  }
  long long ans = 0;
  for (int i = 0; i < n - k; i++) {
    long long tmp = 0;
    tmp = t[i + k] - t[i] + s[i] - s[0] + s[n] - s[i + k];
    ans = max(tmp, ans);
  }
  cout << (ans) << endl;
  return 0;
}
