#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) {
  return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) {
  return make_pair(l.first - r.first, l.second - r.second);
}
const long long int MOD = 1e9 + 7, INF = 1e18;
long long int N, K, arr[100000];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N >> K;
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    cin >> arr[i];
  }
  long long int cnt = 0;
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    if (arr[i] <= 0) {
      cnt++;
      if (cnt == K) {
        long long int _sum = 0;
        for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
          if (arr[i] > 0) {
            _sum += arr[i];
          }
        }
        cout << _sum << endl;
        return 0;
      }
    } else {
      cnt = 0;
    }
  }
  long long int sums[100001];
  sums[0] = 0;
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    sums[i + 1] = sums[i] + arr[i];
  }
  long long int maxv = 0, maxidx = -1;
  for (long long int i = (0), i_end_ = (N - K + 1); i < i_end_; i++) {
    if (sums[i + K] - sums[i] > maxv) {
      maxv = sums[i + K] - sums[i];
      maxidx = i;
    }
  }
  if (maxidx == -1) {
    cout << 0 << endl;
    return 0;
  }
  long long int sum = maxv;
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    if (maxidx <= i && i <= maxidx + K) continue;
    if (arr[i] > 0) {
      sum += arr[i];
    }
  }
  cout << sum << endl;
}
