#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  priority_queue<long long> pq;
  long long a[n];
  long long sumpos = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0) sumpos += a[i];
  }
  long long lp = 0;
  long long rp = 0;
  long long cur = 0;
  for (long long i = 0; i < k; i++) {
    cur += a[rp];
    if (a[rp] > 0) sumpos -= a[rp];
    rp++;
  }
  long long best = cur + sumpos;
  while (rp != n) {
    cur += a[rp];
    if (a[rp] > 0) sumpos -= a[rp];
    rp++;
    cur -= a[lp];
    if (a[lp] > 0) sumpos += a[lp];
    lp++;
    if (cur + sumpos > best) {
      best = cur + sumpos;
    }
  }
  cout << best << '\n';
}
