#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),x.end()
#define fi first
#define sc second
#define pii pair<int,int>
#define endl "\n"

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k,x;
    cin >> n >> k >> x;
    vector<int> niz(n);
    for(int i=0; i<n; i++)cin >> niz[i];
    vector<int> trniz;
    for(int i=0; i<k; i++)trniz.pb(niz[i]);
    vector<int> suf(n+1,0);
    for(int i=n-1; i>=0; i--)suf[i] = suf[i+1] + niz[i];
    multiset<int> setic;
    multiset<int> resenje;
    resenje.insert(0);
    int suma =0;
    for(int i=0; i<k; i++)
    {
        resenje.insert(suf[i]);
        suma+=suf[i];
        if((int)resenje.size() > x)
        {
            auto it = resenje.begin();
            int p = *it;
            setic.insert(p);
            resenje.erase(resenje.find(p));
            suma-=p;
        }
    }
    cout << max(suma-x*suf[k],suma-(x-1)*suf[k])  << " ";

    for(int i=k; i<n; i++)
    {
        int tr = suf[i-k];
        if(resenje.count(tr))
        {
            resenje.erase(resenje.find(tr));
            auto it = --setic.end();
            suma-=tr;
            resenje.insert(*it);
            suma+=*it;
            setic.erase(setic.find(*it));
        }
        else if(setic.count(tr))setic.erase(setic.find(tr));
        resenje.insert(suf[i]);
        suma+=suf[i];
        if((int)resenje.size() > x)
        {
            auto it = resenje.begin();
            int p = *it;
            setic.insert(p);
            resenje.erase(resenje.find(p));
            suma-=p;
        }
        cout <<  max(suma-x*suf[i+1],suma-(x-1)*suf[i+1]) << " ";
    }


}