#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
  return x * f;
}
int n, K, a[MAXN];
long long suf[MAXN], pre[MAXN], ans;
int main() {
  n = read(), K = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = n; i >= 1; i--) suf[i] = suf[i + 1] + a[i];
  for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + a[i];
  long long sum = 0;
  for (int i = 1; i <= n - K; i++) {
    if (a[i] > 0) {
      sum += a[i];
      ans = max(ans, sum + suf[i + K + 1]);
    }
  }
  ans = max(ans, sum + suf[n - K + 1]);
  sum = 0;
  for (int i = n; i > K; i--) {
    if (a[i] > 0) {
      sum += a[i];
      ans = max(ans, sum + pre[i - K - 1]);
    }
  }
  ans = max(ans, sum + pre[K]);
  printf("%lld\n", ans);
  return 0;
}
