#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int MOD = 1000000007;
template <typename T>
void printv(vector<T> const& s) {
  for (int i = (0); i < (s.size()); i++) {
    cout << s[i] << " ";
  }
  cout << endl;
}
int main() {
  cin.tie(0);
  cout << setprecision(10);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
  }
  vector<int> su(n + 1);
  su[0] = 0;
  for (int i = (1); i < (n + 1); i++) {
    su[i] = su[i - 1] + a[i - 1];
  }
  printv(su);
  vector<int> su2(n + 1);
  su2[0] = 0;
  for (int i = (1); i < (n + 1); i++) {
    su2[i] = su2[i - 1] + max(0, a[i - 1]);
  }
  printv(su2);
  int ma = 0;
  int now = 0;
  for (int i = (1); i < (n - k + 2); i++) {
    now = su2[i - 1];
    now += max(0, su[i + k - 1] - su[i - 1]);
    now += su2[n] - su2[i + k - 1];
    cout << now << endl;
    ma = max(ma, now);
  }
  cout << ma << endl;
}
