#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, K, A[100001], B[100001];

int main(void) {
  cin >> N >> K;
  A[0] = B[0] = 0;
  REP(i, 0, N) cin >> A[i + 1];
  REP(i, 0, N) B[i + 1] = max(A[i + 1], 0LL);
  REP(i, 0, N) A[i + 1] += A[i];
  REP(i, 0, N) B[i + 1] += B[i];

  ll ans = 0;
  REP(i, 0, N - K + 1) {
    ll s = B[i] - B[0] + B[N] - B[i + K];
    ans = max({ ans, s, s + A[i + K] - A[i] });
  }
  cout << ans << endl;
}
