#include <bits/stdc++.h>
using namespace std;
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}
template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}
void mainmain() {
  int n;
  cin >> n;
  int K;
  cin >> K;
  vll v(n);
  for (int(i) = (0); (i) < ((n)); ++(i)) cin >> v[i];
  vll a(n);
  vll b(n);
  for (int(i) = (0); (i) < ((n)); ++(i)) {
    if (i) {
      a[i] += a[i - 1];
      b[n - 1 - i] += b[n - i];
    }
    a[i] += max(v[i], 0LL);
    b[n - 1 - i] += max(v[n - 1 - i], 0LL);
  }
  long long sum = 0;
  long long ans = 0;
  for (int(i) = (0); (i) < ((n)); ++(i)) {
    sum += v[i];
    if (i + 1 >= K) {
      ans = max(ans, sum + (i + 1 < n ? b[i + 1] : 0LL) +
                         (i - K >= 0 ? a[i - K] : 0LL));
      sum -= v[i - (K - 1)];
    }
  }
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  mainmain();
}
