#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int N, K;
int a[100010];
int s[100010], p_s[100010];
int main() {
  cin >> N >> K;
  for (int i = 0; i < (int)(N); ++i) cin >> a[i];
  s[0] = p_s[0] = 0;
  for (int i = 0; i < (int)(N); ++i) {
    s[i + 1] = s[i] + a[i];
    p_s[i + 1] = p_s[i] + (a[i] > 0 ? a[i] : 0);
  }
  int ans = 0;
  for (int i = 0; i <= N - K; i++) {
    int t = p_s[i] + p_s[N] - p_s[i + K];
    int u = max(s[i + K] - s[i], 0);
    t += u;
    ans = max(t, ans);
  }
  cout << ans << endl;
}
