#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
struct edge {
  int myc, to, c, cost;
};
struct pos {
  int to, cost, color;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int dp[100005];
vector<pair<long long, int> > G1, G2;
bool d[100005] = {};
queue<int> que;
long long a[100005] = {};
long long b[100005] = {};
long long c[100005] = {};
int main() {
  int n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; ++i) cin >> a[i + 1];
  for (long long i = 0; i < n; ++i) {
    b[i + 1] = b[i];
    if (a[i + 1] > 0) b[i + 1] += a[i + 1];
    c[i + 1] = c[i] + a[i + 1];
  }
  long long t = 0;
  for (long long i = 0; i < n - k; ++i) {
    long long c2 = max((long long)0, c[i + k] - c[i]);
    t = max(t, b[i] + c2 + b[n] - b[i + k]);
  }
  cout << t << endl;
  return 0;
}
