#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int K;
  scanf("%d%d", &N, &K);
  vector<int> S;
  vector<int> A;
  for (int i = (0); i < (N); ++i) {
    int x;
    scanf("%d", &x);
    if (i == 0)
      S.push_back(x);
    else
      S.push_back(x + S.back());
    A.push_back(x);
  }
  long long ans = 0;
  for (int i = K - 1; i <= N - 1; i++) {
    long long now = 0;
    if (i == K - 1) {
      now = max(0, S[K - 1]);
      for (int j = K; j <= N - 1; j++) {
        now += max(0, A[i]);
      }
      ans = max(now, ans);
      continue;
    }
    now = max(0, S[i] - S[i - K]);
    int a = i - K + 1;
    int b = i;
    for (int j = 0; j <= N - 1; j++) {
      if ((a <= j) and (j <= b)) continue;
      now += max(0, A[j]);
    }
    ans = max(now, ans);
  }
  printf("%lld\n", ans);
  ;
  return 0;
}
