#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;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  cin >> v;
  vector<ll> a(n + 1);
  for (int i = (int)(1); i < (int)(n + 1); ++i) a[i] = a[i - 1] + v[i - 1];
  ll maxv = -1001001001;
  int maxi = 0;
  for (int i = (int)(0); i < (int)(n - k + 1); ++i) {
    if (ChangeMax(maxv, a[i + k] - a[i])) maxi = i;
  }
  cerr << "maxv" << ':' << maxv << endl;
  ;
  cerr << "maxi" << ':' << maxi << endl;
  ;
  ll sum = maxv;
  for (int i = (int)(0); i < (int)(maxi); ++i)
    if (v[i] > 0) sum += v[i];
  for (int i = (int)(maxi + k); i < (int)(n); ++i)
    if (v[i] > 0) sum += v[i];
  cout << sum << endl;
  return 0;
}
