#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  long long sum = 0;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0) sum += a[i];
  }
  vector<long long> s(n, 0);
  if (a[0] < 0) s[0] = a[0];
  for (long long i = 1; i < n; i++) s[i] += s[i - 1] + (a[i] < 0 ? a[i] : 0);
  long long MAX = -1e15;
  for (long long i = 0; i < n - k + 1; i++) {
    MAX = max(MAX, s[i + k - 1] - s[i]);
  }
  long long ans = max((long long)0, sum + MAX);
  cout << ans << endl;
}
