#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
int N;
int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> a(N), b(N);
  for (int i = 0; i < N; i++) {
    long long tmp;
    cin >> tmp;
    if (i == 0) {
      a[0] = b[0] = tmp;
    } else {
      if (tmp > 0) {
        b[i] = b[i - 1] + tmp;
      } else {
        b[i] = b[i - 1];
      }
      a[i] = a[i - 1] + tmp;
    }
  }
  long long ans = b[N - 1] - b[K - 1];
  if (a[K - 1] > 0) ans += a[K - 1];
  for (int i = K; i <= N - 1; i++) {
    long long tmp = b[i - K] + b[N - 1] - b[i];
    if (a[i] - a[i - K] > 0) tmp += a[i] - a[i - K];
    if (tmp > ans) {
      ans = tmp;
    }
  }
  cout << (ans > 0 ? ans : 0);
}
