#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
int n, k;
long long p[N];
long long pref[N], pref2[N];
long long query(int l, int r) {
  if (l > r) return 0;
  return pref[r] - pref[l - 1];
}
long long query2(int l, int r) {
  if (l > r) return 0;
  return pref2[r] - pref2[l - 1];
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", p + i);
  }
  for (int i = 1; i <= n; ++i) {
    pref[i] = p[i] + pref[i - 1];
    pref2[i] = p[i] > 0 ? p[i] : 0;
    pref2[i] += pref2[i - 1];
  }
  long long sol = 0;
  for (int i = 1; i <= n; ++i) {
    if (i + k - 1 > n) break;
    sol = max(sol, query2(1, i - 1) + query(i, i + k - 1) + query2(i + k, n));
  }
  printf("%lld\n", sol);
  return 0;
}
