#include <bits/stdc++.h>
using namespace std;
const int MAXN = int(2e5);
const int MOD = int(360);
const int oo = INT_MAX;
int n, k;
long long arr[MAXN];
long long acc_l[MAXN], acc_r[MAXN], acc[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  while (cin >> n >> k) {
    acc[0] = 0;
    for (int i = 1; i <= n; ++i) {
      cin >> arr[i];
      acc[i] = acc[i - 1] + arr[i];
    }
    acc_l[0] = 0;
    for (int i = 1; i <= n; ++i) {
      acc_l[i] = acc_l[i - 1] + (arr[i] > 0 ? arr[i] : 0);
    }
    acc_r[n + 1] = 0;
    for (int i = n; i > 0; --i) {
      acc_r[i] = acc_r[i + 1] + (arr[i] > 0 ? arr[i] : 0);
    }
    long long ans = 0;
    for (int i = 1; i + k - 1 <= n; ++i) {
      long long cur = acc_l[i - 1] + acc_r[i + k];
      long long val = acc[i + k - 1] - acc[i - 1];
      if (val > 0) {
        cur += val;
      }
      ans = max(ans, cur);
    }
    cout << ans << '\n';
  }
  return 0;
}
