#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("avx2")

using namespace std;
using ll = long long;
#define pb push_back

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x, k;
    cin >> n >> k >> x;
    ll s[n+2], a[n+2];  s[n+1] = 0;
    for (int i = 1; i <= n; ++i)    cin >> a[i];
    for (int i = n; i >= 1; --i)    s[i] = s[i+1]+a[i];
    multiset<ll> u, v;
    ll S = 0;
    for (int i = 2; i <= k+1; ++i)    u.insert(s[i]);
    while (v.size() != x-1) {
        ll t = *u.rbegin();
        u.erase(u.find(t));
        v.insert(t);
        S += t;
    }
    cout << S+s[1]-x*s[k+1] << ' ';
    for (int i = k+2; i <= n+1; ++i) {
        if (u.find(s[i-k]) != u.end()) {
            u.erase(u.find(s[i-k]));
            if (s[i] > *v.begin()) {
                S -= *v.begin();
                v.erase(v.begin());
                S += s[i];
                v.insert(s[i]);
            }
            else
                u.insert(s[i]);
        }
        else {
            v.erase(v.find(s[i-k]));
            S -= s[i-k];
            if (*u.rbegin() > s[i]) {
                S += *u.rbegin();
                v.insert(*u.rbegin());
                u.erase(u.lower_bound(*u.rbegin()));
            }
            else {
                S += s[i];
                v.insert(s[i]);
            }
        }
        cout << S+s[i-k]-x*s[i] << ' ';
    }
    cout << '\n';
}