#include <bits/stdc++.h>
using namespace std;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
const int inf = (int)1.01e9;
const long double eps = 1e-9;
const long double pi = acos((long double)-1.0);
const int mod = (int)1e9 + 7;
void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}
int mult(int x, int y) { return (long long)x * y % mod; }
int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}
void precalc() {}
const int maxn = (int)1e5 + 10;
int a[maxn];
int n, k;
int read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  return 1;
}
void solve() {
  long long res = -1e18, bal = 0;
  for (int iter = 0; iter < 2; ++iter) {
    for (int i = 0; i < n; ++i) {
      bal += min(a[i], 0);
      if (i >= k - 1) {
        res = max(res, bal);
        bal -= min(a[i - k + 1], 0);
      }
    }
    for (int i = 0; i < n; ++i) {
      a[i] = -a[i];
    }
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] > 0) {
      res += a[i];
    }
  }
  printf("%lld\n", res);
}
int main() {
  precalc();
  while (1) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}
