#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<long long> a(N), sum(N + 1), sum2(N + 1, 0);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum[i + 1] = a[i];
    sum2[i + 1] = sum2[i];
    if (a[i] > 0) sum2[i + 1] += a[i];
  }
  for (int i = 1; i <= N; i++) sum[i] += sum[i - 1];
  long long tmp = 0;
  int idx = -1;
  for (int i = 0; i <= N - K; i++) {
    long long tmp2 = sum2[i] + sum[i + K] - sum[i];
    if (tmp < tmp2) {
      idx = i;
      tmp = tmp2;
    }
  }
  long long ans = tmp;
  for (int i = idx + K - 1; i >= idx; i--) {
    if (i < K) break;
    long long tmp2 = sum2[idx] - sum2[i - K] + sum[i] - sum[idx];
    if (tmp2 < 0) {
      ans = max(ans, tmp - tmp2);
    }
  }
  cout << ans << endl;
  return 0;
}
