#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, k;
int a[N];
long long f[N], s[N];
long long ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i], f[i] = f[i - 1] + max(0, a[i]);
  for (int i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i];
  for (int lst = n - k + 1; lst >= 1; --lst) {
    int nxt = lst + k - 1;
    ans = max(ans, f[lst - 1] + s[nxt] - s[lst - 1]);
  }
  cout << ans << endl;
}
