#include <bits/stdc++.h>

using namespace std;

int main()
{

    int n,k,x;
    cin>>n>>k>>x;
    vector<long long> p(n);
    for(int i=0;i<n;i++)
        cin>>p[i];
    vector<long long> akt(n+1,0);
    for(int i=0;i<n;i++)
        akt[i+1]=akt[i]+p[i];
    int t = x-1;
    multiset<long long> al, ma;
    long long osszal = 0;

    auto ertek = [&](long long v)
    {
        if(t==0)
            ma.insert(v);

        if((int)al.size() < t)
        {
            al.insert(v);
            osszal += v;
        }
        auto it = prev(al.end());
        if(v < *it)
        {
            long long mv = *it;
            al.erase(it);
            osszal -= mv;
            al.insert(v);
            osszal += v;
            ma.insert(mv);
        }
        else ma.insert(v);
    };
    auto torol = [&](long long v)
    {
        if(t==0)
        {
            auto it = ma.find(v);
            if(it!=ma.end())
                ma.erase(it);
        }
        auto itl = al.find(v);
        if(itl != al.end())
        {
            osszal -= v;
            al.erase(itl);
            if(!ma.empty())
            {
                auto ith = ma.begin();
                long long mv = *ith;
                ma.erase(ith);
                al.insert(mv);
                osszal += mv;
            }
        }
        else
        {
            auto ith = ma.find(v);
            if(ith!=ma.end())
                ma.erase(ith);
        }
    };

    for(int i=1;i<=k;i++)
        ertek(akt[i]);
    vector<long long> valasz;
    valasz.reserve(n-k+1);
    for(int s=0;s+k<=n;s++)
    {
        long long a = (long long)x * akt[s+k] - akt[s] - osszal;
        valasz.push_back(a);
        if(s+k < n)
        {
            torol(akt[s+1]);
            ertek(akt[s+k+1]);
        }
    }
    for(size_t i=0;i<valasz.size();i++)
    {
        if(i)
            cout << ' ';
        cout << valasz[i];
    }
    cout << endl;
    return 0;
}