#include <bits/stdc++.h>
using namespace std;
void solve(long long N, long long K, vector<long long> a) {
  bool pls = false;
  long long sum = 0;
  for (long long n : a) {
    if (n > 0) {
      pls = true;
    }
    sum += n;
  }
  if (pls == false) {
    printf("0\n");
    return;
  }
  if (a.size() <= K) {
    if (sum > 0) {
      printf("%lld\n", sum);
      return;
    }
    printf("0\n");
    return;
  } else {
    vector<long long> candidates;
    for (long long i = 0; i <= a.size() - K; i++) {
      long long ksum = 0, psum = 0;
      for (long long j = i; j < i + K; j++) {
        ksum += a[j];
      }
      for (long long j = 0; j < i; j++) {
        if (a[j] > 0) psum += a[j];
      }
      for (long long j = i + K; j < a.size(); j++) {
        if (a[j] > 0) psum += a[j];
      }
      if (ksum >= 0) {
        candidates.push_back(ksum + psum);
      } else {
        candidates.push_back(psum);
      }
    }
    printf("%lld\n", *std::max_element(candidates.begin(), candidates.end()));
  }
}
int main() {
  long long K;
  long long N;
  scanf("%lld", &N);
  vector<long long> a(N - 1 + 1);
  scanf("%lld", &K);
  for (int i = 0; i <= N - 1; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, K, a);
  return 0;
}
