#include <bits/stdc++.h>
using namespace std;
long long N, K;
long long a[100010];
long long b[100010];
long long c[100010];
int main() {
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> a[i];
  b[1] = a[1];
  for (int i = 2; i <= N; i++) {
    b[i] = a[i] + b[i - 1];
  }
  if (a[1] > 0) c[1] = a[1];
  for (int i = 2; i <= N; i++) {
    if (a[i] > 0)
      c[i] = a[i] + c[i - 1];
    else
      c[i] = c[i - 1];
  }
  long long ans = -1;
  for (int i = 1; i <= N - K + 1; i++) {
    ans = max(ans,
              (b[K - 1 + i] - b[i - 1]) + c[i - 1] + (c[N - 1] - c[K - 1 + i]));
  }
  if (ans == -1)
    cout << 0 << endl;
  else
    cout << ans << endl;
  return 0;
}
