#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
const long long int N = 1e5 + 9;
const long long int mod = 998244353;
long long int powm(long long int a, long long int b) {
  a = a % mod;
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
long long int a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int ps[n], ps1[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      ps[i] = max(0ll, a[i]);
      ps1[i] = a[i];
    }
    for (int i = 1; i < n; i++) {
      ps[i] += ps[i - 1];
      ps1[i] += ps1[i - 1];
    }
    long long int ans = 0;
    for (int i = 0; i < n - k; i++) {
      long long int te = 0;
      if (i == 0) {
        te = ps[n - 1] - ps[i + k - 1] + ps1[i + k - 1];
      } else {
        te = ps[n - 1] - ps[i + k - 1] + ps[i - 1] +
             max(ps1[i + k - 1] - ps1[i - 1], 0ll);
      }
      ans = max(ans, te);
    }
    cout << ans << '\n';
  }
}
