#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
ll N, K;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  vector<ll> A(N + 1, 0);
  for (ll i = 0; i <= N; i++) {
    cin >> A[i];
  }
  auto B = A;
  for (auto&& b : B) {
    b = max(0LL, b);
  }
  for (ll i = 1; i <= N; i++) {
    A[i] += A[i - 1];
    B[i] += max(0LL, B[i - 1]);
  }
  for (auto a : A) {
    cout << a << " ";
  }
  cout << endl;
  for (auto b : B) {
    cout << b << " ";
  }
  cout << endl;
  ll ans = 0;
  for (ll i = 0; i <= N - K; i++) {
    ll white = B.back() - (B[i + K] - B[i]);
    ll black = B.back() - (B[i + K] - B[i]) + (A[i + K] - A[i]);
    ans = max(ans, max(black, white));
  }
  cout << ans << endl;
  return 0;
}
