#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
using P = pair<T, U>;
template <class T>
using Heap = priority_queue<T>;
template <class T>
using heaP = priority_queue<T, vector<T>, greater<T>>;
template <class T>
bool ChangeMax(T& a, const T& b) {
  if (a >= b) return false;
  a = b;
  return true;
}
template <class T>
bool ChangeMin(T& a, const T& b) {
  if (a <= b) return false;
  a = b;
  return true;
}
template <class T, size_t N, class U>
void Fill(T (&a)[N], const U& v) {
  fill((U*)a, (U*)(a + N), v);
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& e : v) is >> e;
  return is;
}
ll GetSum(int l, int r, vector<ll>& v) {
  if (l > r || l >= (int)v.size() || r < 0) return 0;
  int lval = l == 0 ? 0 : v[l - 1];
  return v[r] - lval;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  cin >> v;
  vector<ll> a(n), b(n);
  ll apre = 0, bpre = 0;
  for (int i = (int)(0); i < (int)(n); ++i) {
    apre = a[i] = apre + v[i];
    bpre = b[i] = bpre + max(0, v[i]);
  }
  ll ans = 0;
  k--;
  for (int i = (int)(0); i < (int)(n); ++i) {
    if (i + k >= n) break;
    cerr << "GetSum(i, i + k, a)" << ':' << GetSum(i, i + k, a) << endl;
    ;
    ChangeMax(ans, max((ll)0, GetSum(i, i + k, a)) + GetSum(0, i - 1, b) +
                       GetSum(i + k + 1, n - 1, b));
  }
  cout << ans << endl;
  return 0;
}
