#include <bits/stdc++.h>
using namespace std;
long long part(int l, int r, vector<long long> s) { return s[r] - s[l]; }
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  vector<long long> sum(N + 1);
  for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];
  vector<long long> psum(N + 1);
  for (int i = 0; i < N; i++) {
    if (a[i] > 0)
      psum[i + 1] = psum[i] + a[i];
    else
      psum[i + 1] = psum[i];
  }
  long long ans = 0;
  for (int i = 0; i + K <= N; i++) {
    long long tmp = part(0, i, psum) + part(i + K, N, psum);
    long long b = part(i, i + K, sum);
    if (b > 0) tmp += b;
    if (ans < tmp) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}
