#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
const long long maxn = 1e5 + 10, lg = 64, mod = 1e9 + 7, inf = 1e18;
long long n, k, a[maxn];
long long l[maxn], r[maxn], ps[maxn];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ps[i] = ps[i - 1] + a[i];
    l[i] = l[i - 1] + max(0ll, a[i]);
  }
  for (int i = n; i >= 1; i--) r[i] = r[i + 1] + max(0ll, a[i]);
  long long ans = 0;
  for (int i = 1; i <= n - k; i++)
    ans = max(ans, l[i] + r[i + k + 1] + max(0ll, ps[i + k] - ps[i]));
  cout << ans << endl;
  return 0;
}
