#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[100100];
int qzh[100100];
bool color[100100];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    qzh[i] = qzh[i - 1] + a[i];
  }
  for (int i = k; i <= n; i++) {
    if (qzh[i] - qzh[i - k] > 0) {
      for (int j = i - k + 1; j <= i; j++) color[j] = 1;
    } else {
      for (int j = i - k + 1; j <= i; j++) color[j] = 0;
    }
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    res += (long long)(color[i]) * (long long)(a[i]);
  }
  cout << res << endl;
  return 0;
}
