#include <bits/stdc++.h>
using namespace std;
int K;
int N;
int a[100000 + 1];
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int all_pos = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] > 0) {
      all_pos += a[i];
    }
  }
  int b[N - K];
  int pos[N - K];
  memset(pos, 0, sizeof(int));
  for (int i = 0; i <= N - K; i++) {
    int all_black = 0;
    pos[i] = 0;
    for (int k = 0; k < K; k++) {
      all_black += a[i + k];
      pos[i] += max(a[i + k], (int)0);
    }
    b[i] = max(all_black, (int)0);
  }
  int m = 0;
  for (int i = 0; i <= N - K; i++) {
    m = max(m, all_pos - pos[i] + b[i]);
  }
  cout << m << endl;
}
