#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &res) {
  res = 0;
  T f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
  }
  res *= f;
}
template <class T>
void out(T x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x >= 10) {
    out(x / 10);
  }
  putchar('0' + x % 10);
}
int N, K;
long long pre[5005], suf[5005], a[5005], sum[5005];
void Solve() {
  read(N);
  read(K);
  for (int i = 1; i <= N; ++i) {
    read(a[i]);
    sum[i] = sum[i - 1] + a[i];
    pre[i] = pre[i - 1];
    if (a[i] > 0) pre[i] = pre[i] + a[i];
  }
  for (int i = N; i >= 1; --i) {
    suf[i] = suf[i + 1];
    if (a[i] > 0) suf[i] = suf[i] + a[i];
  }
  long long ans = 0;
  for (int i = 1; i <= N; ++i) {
    int r = i + K - 1;
    if (r > N) break;
    long long all = pre[i - 1] + suf[r + 1];
    if (sum[r] - sum[i - 1] > 0) all += sum[r] - sum[i - 1];
    ans = max(ans, all);
  }
  out(ans);
  putchar('\n');
}
int main() {
  Solve();
  return 0;
}
