#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const long long INF = (1ll << 60) - 1;
int n, k;
int a[MAXN];
long long ans;
long long sum1[MAXN];
long long sum2[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum1[i] = sum1[i - 1] + a[i];
    sum2[i] = sum2[i - 1] + max(a[i], 0);
  }
  ans = -INF;
  for (int i = 1; i + k - 1 <= n; i++)
    ans = max(ans, max(0ll, sum1[i + k - 1] - sum1[i]) + sum2[n] -
                       sum2[i + k - 1] + sum2[i - 1]);
  cout << ans << endl;
  return 0;
}
