#include <bits/stdc++.h>
using namespace std;
const int mxn = 100002;
int n, k;
int a[mxn];
long long second[2][mxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int t = 0; t < 2; t++) {
    for (int i = 1; i <= n; i++) {
      second[t][i] = max(0, a[i]) + second[t][i - 1];
    }
    reverse(a, a + n + 2);
  }
  reverse(second[1], second[1] + n + 2);
  for (int i = 1; i <= n; i++) a[i] += a[i - 1];
  long long ret = 0xcfcfcfcfcfcfcfcf;
  for (int i = 1; i <= n - k + 1; i++) {
    ret = max(ret, second[0][i - 1] + second[1][i + k] +
                       max(0, a[i + k - 1] - a[i - 1]));
  }
  cout << ret << '\n';
  return 0;
}
