#include <bits/stdc++.h>
using namespace std;
int N, K;
long long A[100000];
long long res = -(1LL << 62);
long long around, center;
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = K; i < N; ++i) around += max(0LL, A[i]);
  for (int i = 0; i < K; ++i) center += A[i];
  res = max(res, around + max(0LL, center));
  for (int i = 0; i < N - K - 1; ++i) {
    center -= A[i];
    center += A[i + K];
    around += max(0LL, A[i]);
    around -= max(0LL, A[i + K]);
    res = max(res, around + max(0LL, center));
  }
  cout << res << endl;
  return 0;
}
