#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
long long int power(long long int x, long long int n, long long int M) {
  long long int tmp = 1;
  if (n > 0) {
    tmp = power(x, n / 2, M);
    if (n % 2 == 0)
      tmp = (tmp * tmp) % M;
    else
      tmp = (((tmp * tmp) % M) * x) % M;
  }
  return tmp;
}
long long int N, M, K, Q, W, H, L, R;
long long int ans;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  long long int num[100001] = {};
  long long int sum[100001] = {};
  long long int big[100001] = {};
  for (int i = 1; i <= N; i++) {
    cin >> num[i];
    sum[i] = sum[i - 1] + num[i];
    big[i] = big[i - 1] + max(num[i], (long long int)0);
  }
  for (int i = 1; (i + M - 1) <= N; i++) {
    long long int box = 0;
    box = sum[i + M - 1] - sum[i - 1];
    box += big[N];
    box -= big[i + M - 1];
    box += big[i - 1];
    ans = max(ans, box);
  }
  cout << ans << endl;
  return 0;
}
