#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long LINF = 1LL << 62;
const int INF = 1 << 17;
int main() {
  int N, K;
  cin >> N >> K;
  long long a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  long long sum = 0;
  for (int i = 0; i < K; i++) {
    sum += a[i];
  }
  long long maxi = sum, mini = sum;
  int r = 0, l = K, u = 0, v = K;
  for (int i = 0; i < N - K; i++) {
    sum = sum + a[i + K] - a[i];
    if (sum > maxi) {
      r = i + 1, l = i + K + 1;
      maxi = sum;
    }
    if (sum < mini) {
      u = i + 1, v = i + K + 1;
      mini = sum;
    }
  }
  long long ans = 0;
  if (maxi > 0) {
    for (int i = 0; i < r; i++) {
      if (a[i] > 0) ans += a[i];
    }
    for (int i = l; i < N; i++) {
      if (a[i] > 0) ans += a[i];
    }
    ans += maxi;
  } else {
    for (int i = 0; i < u; i++) {
      if (a[i] > 0) ans += a[i];
    }
    for (int i = v; i < N; i++) {
      if (a[i] > 0) ans += a[i];
    }
  }
  cout << ans << endl;
  return 0;
}
