#include <bits/stdc++.h>
using namespace std;
vector<long long> sum(100001), sum2(100001);
int n, k, x[100001];
long long Sum(int i) { return sum[i + k] - sum[i]; }
long long Sum(int l, int r) {
  if (l == r) return 0;
  return sum2[r] - sum2[l];
}
long long dfs2(int);
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    sum[i + 1] += x[i] + sum[i];
    sum2[i + 1] += sum2[i];
    if (x[i] > 0) sum2[i + 1] += x[i];
  }
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    long long sum = 0;
    if (i + k >= n) break;
    if (Sum(i) > 0) sum = Sum(i);
    sum += Sum(0, i) + Sum(i + k, n);
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
