#include <bits/stdc++.h>
using namespace std;
long long a[100010];
long long sum_all[100010], sum_plus[100010];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < (n); ++i) {
    sum_all[i + 1] = sum_all[i] + a[i];
    sum_plus[i + 1] = sum_plus[i] + (a[i] >= 0 ? a[i] : 0);
  }
  long long ans = 0;
  for (int i = 1; i <= n - k + 1; ++i) {
    ans = max(ans, (sum_all[i + k - 1] - sum_all[i - 1]) +
                       ((sum_plus[n] - sum_plus[0]) -
                        (sum_plus[i + k - 1] - sum_plus[i - 1])));
  }
  cout << ans << endl;
}
