#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const long long mod = 1000000007;
const long long inf = long long(1e9);
const long long half_inf = long long(1e5);
const long long ll_inf = long long(1e9) * long long(1e9);
unordered_map<long long, long long> mp;
long long n, k;
vector<long long> a;
void solve() {
  long long dp[n + 1];
  dp[0] = 0;
  for (long long i = 0; i < (long long)(n); i++) dp[i + 1] = dp[i] + a[i];
  long long ans = -inf, s = 0;
  for (int i = 1; i + k - 1 <= n; ++i) {
    long long temp = dp[i + k - 1] - dp[i];
    if (ans < temp) {
      ans = temp;
      s = i;
    }
  }
  for (long long i = 0; i < (long long)(n); i++) {
    if (i >= s - 1 && i <= s - 1 + k - 1)
      continue;
    else
      ans += max(long long(0), a[i]);
  }
  cout << ans << endl;
}
int main() {
  cin >> n >> k;
  a.resize(n);
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  solve();
  return 0;
}
