#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  int left = 0;
  int right = 0;
  long long val = 0;
  long long ans = -INF;
  int mleft = 0;
  int mright = 0;
  for (int i = 0; i < n; i++) {
    int nleft = i;
    int nright = min(i + k, n);
    while (left < nleft) {
      val -= a[left];
      left++;
    }
    while (right < nright) {
      val += a[right];
      right++;
    };
    if (ans < val) {
      ans = val;
      mleft = left;
      mright = right;
    }
  };
  while (0 < mleft) {
    mleft--;
    if (a[mleft] > 0) ans += a[mleft];
  }
  while (mright < n) {
    if (a[mright] > 0) ans += a[mright];
    mright++;
  }
  cout << max(0ll, ans) << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
