#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
int N;
int K;
long long a[100010];
long long nsum[100010];
long long psum[100010];
long long ans;
int main() {
  cin >> N >> K;
  for (int i = 1; i < N + 1; i++) {
    cin >> a[i - 1];
    nsum[i] = nsum[i - 1] + min<long long>(0, a[i - 1]);
    psum[i] = psum[i - 1] + max<long long>(0, a[i - 1]);
  }
  for (int i = 1; i < N - K + 1; i++) {
    long long kuro = psum[N] + (nsum[i + K] - nsum[i]);
    long long siro = psum[N] - (psum[i + K] - psum[i]);
    ans = max({ans, siro, kuro});
  }
  cout << (ans) << endl;
  return 0;
}
