#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N, K;
long long A[100001];
long long T[100001];

int main() {
  cin >> N >> K;
  for (int i=1; i<=N; i++) {
    cin >> A[i];
    T[i] = A[i] + T[i-1];
  }
  long long ans = 0;
  long long h = 0, t = 0;
  for (int i=K+1; i<=N; i++) t += max(A[i], 0LL);
  for (int i=1; i<=N-K+1; i++) {
    ans = max(ans, max(T[i+K-1] - T[i-1], 0LL) + h + t);
    h += max(A[i], 0LL);
    t -= max(A[i+K], 0LL);
  }
  cout << ans << "\n";
  return 0;
}
