#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  long long a[N + 2], b[N + 2];
  a[0] = a[N + 1] = b[0] = b[N + 1] = 0ll;
  for (int i = (int)1; i < (int)N + 1; i++) {
    cin >> a[i];
    b[i] = max(a[i], 0ll);
  }
  for (int i = (int)1; i < (int)N; i++) {
    a[i + 1] += a[i];
    b[i + 1] += b[i];
  }
  long long rsl = 0ll;
  for (int i = 0; i + K <= N + 1; i++) {
    long long tmp = a[i] + b[i + K] - b[i] + a[N] - a[i + K];
    rsl = max(rsl, tmp);
  }
  cout << rsl << endl;
}
