#include <bits/stdc++.h>
using namespace std;
int N, K;
int A[100010];
long long sums[3][100010];
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) sums[0][i + 1] = sums[0][i] + A[i];
  for (int i = 0; i < N; i++) sums[1][i + 1] = sums[1][i] + max(0, A[i]);
  for (int i = N - 1; i >= 0; i--) sums[2][i] = sums[2][i + 1] + max(0, A[i]);
  int ans = 0;
  for (int k = 0; k + K <= N; k++) {
    int sum =
        sums[1][k] + sums[2][k + K] + max(sums[0][k + K] - sums[0][k], 0LL);
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
