#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long> dij;
struct edge {
  long long to, cost;
};
vector<vector<edge> > G;
bool isb[100005];
int main() {
  long long a, b, k[100005], ans = 0;
  cin >> a >> b;
  for (int i = 0; i < a; ++i) {
    cin >> k[i];
  }
  for (int i = 0; i <= a - b; ++i) {
    long long mon = 0;
    for (int j = i; j <= b + i - 1; ++j) {
      mon += k[j];
    }
    if (mon < 0) {
      continue;
    }
    isb[i] = 1;
  }
  for (int i = 0; i < a; ++i) {
    if (isb[i]) {
      ans += k[i];
    }
    if (i > b) {
      ans += k[i];
    }
  }
  cout << ans << endl;
}
