#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long LINF = (long long)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void print(const vector<int> &v) {
  for (auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<long long> a(n), b(n + 1, 0), c(n + 1, 0);
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < (n); ++i) {
    b[i + 1] = b[i] + a[i];
    c[i + 1] = c[i] + max<long long>(0, a[i]);
  }
  long long ans = -LINF;
  for (int i = 0; i + k <= n; ++i) {
    int left = c[i] - c[0];
    int right = c[n] - c[i + k];
    if (b[i + k] - b[i] >= 0) {
      ans = max<long long>(ans, b[i + k] - b[i] + left + right);
    } else {
      ans = max<long long>(ans, left + right);
    }
  }
  cout << ans << endl;
  return 0;
}
