#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int v = 100001;
int main() {
  int n, k;
  cin >> n >> k;
  int a[v], b[v], c[v], d[v] = {};
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    b[i] = b[i - 1] + max(a[i], 0);
    c[i] = c[i - 1] + a[i];
  }
  int ans = -INF;
  for (int i = 1; i < n - k + 2; i++) {
    d[i] = c[i + k - 1] - c[i - 1];
    ans = max(ans, d[i] + b[i - 1] + b[n] - b[n - i + 1]);
  }
  cout << ans << endl;
}
