#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 123;
const int M = 123;
const double Pi = acos(-1);
const long long Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;
void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) { return 1ll * a * b % mod; }
int sum(int a, int b) {
  add(a, b);
  return a;
}
int n, k, a[N];
long long second[N], p[N], S[N];
void solve() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[i] = p[i - 1] + max(0, a[i]);
    S[i] = S[i - 1] + a[i];
  }
  for (int i = n; i; i--) {
    second[i] = second[i + 1] + max(0, a[i]);
  }
  long long ans = -1e18;
  for (int i = 1; i + k - 1 <= n; i++) {
    long long now =
        p[i - 1] + second[i + k] + max(0ll, S[i + k - 1] - S[i - 1]);
    ans = max(ans, now);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  int tt = 1;
  while (tt--) solve();
  return 0;
}
