#include <bits/stdc++.h>
using namespace std;
int read() {
  int q = 0, w = 1;
  char ch = ' ';
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') q = q * 10 + ch - '0', ch = getchar();
  return q * w;
}
const int N = 100005;
int n, K, mid, mxd, a[N];
long long mi, mx, sum, ans1, ans2;
int main() {
  n = read(), K = read();
  for (register int i = 1; i <= n; ++i) a[i] = read();
  for (register int i = 1; i <= K; ++i) sum += a[i];
  mi = sum, mid = K, mx = sum, mxd = K;
  for (register int i = K + 1; i <= n; ++i) {
    sum += a[i] - a[i - K];
    if (sum < mi) mi = sum, mid = i;
    if (sum > mx) mx = sum, mxd = i;
  }
  for (register int i = 1; i <= n; ++i) {
    if ((i < mid - K + 1 || i > mid) && a[i] > 0) ans1 += a[i];
    if ((i < mxd - K + 1 || i > mxd) && a[i] > 0) ans2 += a[i];
  }
  printf("%lld\n", max(ans1, ans2 + mx));
  return 0;
}
