#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
pair<int, int> Dir[8] = {{0, 1}, {-1, 0}, {1, 0},  {0, -1},
                         {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
signed main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> asmsum(n + 2), assum(n + 2);
  int sum = 0;
  for (int i = (0); (n) > i; i++) {
    int a;
    scanf("%d", &a);
    if (a > 0) {
      sum += a;
      assum[i + 1] += a;
    } else {
      asmsum[i + 1] += a;
    }
    assum[i + 2] = assum[i + 1];
    asmsum[i + 2] = asmsum[i + 1];
  }
  int ans = INT_MAX;
  for (int i = (0); (n - k + 1) > i; i++) {
    ans = min(ans, assum[i + k] - assum[i]);
    ans = min(ans, abs(asmsum[i + k] - asmsum[i]));
  }
  printf("%d\n", sum - ans);
  return 0;
}
