#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> a(N);
  vector<long long> sum(N);
  for (long long i = 0; i < N; i++) cin >> a[i];
  sum[0] = a[0];
  for (long long i = 1; i < N; i++) {
    sum[i] = a[i];
    sum[i] += sum[i - 1];
  }
  long long pmax = sum[K - 1], max_point = -1;
  long long pmin = sum[K - 1], min_point = -1;
  for (long long i = 0; i < N - K; i++) {
    if (pmax < sum[i + K] - sum[i]) {
      pmax = sum[i + K] - sum[i];
      max_point = i;
    }
    if (pmin > sum[i + K] - sum[i]) {
      pmin = sum[i + K] - sum[i];
      min_point = i;
    }
  }
  long long ans1 = 0, ans2 = 0;
  for (long long i = 0; i < N; i++) {
    if (max_point + 1 <= i && i <= max_point + K) continue;
    if (a[i] > 0) ans1 += a[i];
  }
  for (long long i = 0; i < N; i++) {
    if (min_point + 1 <= i && i <= min_point + K) continue;
    if (a[i] > 0) ans2 += a[i];
  }
  ans1 += (max_point == -1 ? sum[K - 1] : sum[max_point + K] - sum[max_point]);
  cout << (ans1 > ans2 ? ans1 : ans2) << endl;
}
