#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<long long> a;
template <class T>
void readVector(int n, vector<T> &v) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}
long long sum, ans;
int main() {
  cin >> n >> k;
  readVector(n, a);
  vector<long long> b(a);
  for (int i = 0; i < n; ++i)
    if (b[i] < 0) b[i] = 0;
  for (int i = 1; i < n; ++i) {
    b[i] += b[i - 1];
    a[i] += a[i - 1];
  }
  sum = a[n - 1];
  for (int i = 0; i + k - 1 < n; ++i) {
    long long pl, mi;
    pl = (i == 0 ? b[k - 1] : (b[i + k - 1] - b[i - 1]));
    mi = (i == 0 ? a[k - 1] : (a[i + k - 1] - a[i - 1]));
    ans = max(ans, sum + pl - mi);
  }
  cout << ans << "\n";
}
