#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) { cout << (expr ? "Yes" : "No") << "\n"; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, K;
  cin >> N >> K;
  vector<lint> a(N);
  for (int i = (0), i_end_ = (N); i < i_end_; i++) cin >> a[i];
  vector<lint> S(N + 1);
  for (int i = (0), i_end_ = (N); i < i_end_; i++) S[i + 1] += S[i] + a[i];
  vector<lint> Splus(N + 1);
  for (int i = (0), i_end_ = (N); i < i_end_; i++)
    Splus[i + 1] += Splus[i] + (a[i] > 0 ? a[i] : 0);
  lint ans = 0;
  for (int i = (0), i_end_ = (K); i < i_end_; i++) {
    if (i + K > N) break;
    if (S[i + K] - S[i] + Splus[N] - Splus[i + K] > ans)
      ans = S[i + K] - S[i] + Splus[N] - Splus[i + K];
    if (S[i] - S[0] + Splus[N] - Splus[i + K] > ans)
      ans = S[i] - S[0] + Splus[N] - Splus[i + K];
  }
  for (int i = (0), i_end_ = (K); i < i_end_; i++) {
    if (N - i - K < 0) break;
    if (S[N - i] - S[N - i - K] + Splus[N - i - K] > ans)
      ans = S[N - i] - S[N - i - K] + Splus[N - i - K];
    if (S[N] - S[N - i] + Splus[N - i - K] > ans)
      ans = S[N] - S[N - i] + Splus[N - i - K];
  }
  cout << ans << endl;
}
