#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int tx[8] = {-1, 0, 1, -1, 1, -1, 0, 1},
          ty[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int main() {
  ll n, k, a[100010], rui[100010], sei[100010], ans = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    rui[i] = rui[i - 1] + a[i];
    if (a[i] > 0)
      sei[i] = sei[i - 1] + a[i];
    else
      sei[i] = sei[i - 1];
  }
  for (int i = 1; i <= n - k + 1; i++) {
    ll sum = rui[i + k - 1] - rui[i];
    sum += sei[i - 1] + sei[n] - sei[i + k - 1];
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
