#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
const int N=2e5+50;
int n,K,x;
ll pref[N];
set<pair<ll,int>>st,st1;
ll Sum;
vector<ll>res;
int main(){
    scanf("%i%i%i",&n,&K,&x);
    x--;
    st.insert({pref[0],0});
    res.reserve(n);
    for(int i=1;i<=n;i++){
        int X;scanf("%i",&X);
        pref[i]=pref[i-1]+X;
        Sum+=pref[i];
        st.insert({pref[i],i});
        if(i>=K){
            if(st.find({pref[i-K],i-K})!=st.end()){
                Sum-=pref[i-K];
                st.erase({pref[i-K],i-K});
            }
            else{
                st1.erase({pref[i-K],i-K});
            }
        }
        while(st1.size()&&st.size()<x){
            auto [y,j]=*st1.begin();
            Sum+=y;
            st.insert({y,j});
            st1.erase({y,j});
        }
        while(st.size()>x){
            auto [y,j]=*st.rbegin();
            Sum-=y;
            st.erase({y,j});
            st1.insert({y,j});
        }
        while(st.size()&&st1.size()&&(*st.rbegin()).fi>(*st1.begin()).fi){
            auto [y1,j1]=*st.rbegin();
            auto [y2,j2]=*st1.begin();
            Sum-=y1;
            st.erase({y1,j1});
            Sum+=y2;
            st.insert({y2,j2});
            st1.erase({y2,j2});
            st1.insert({y1,j1});
        }
        if(i>=K)res.pb(pref[i]*x-Sum+pref[i]-pref[i-K]);
        //printf("%i:\n",i);
        //for(auto [y,j]:st)printf("[%i,%i] ",y,j);printf("\n");
        //for(auto [y,j]:st1)printf("[%i %i] ",y,j);printf("\n");
    }
    for(auto i:res)printf("%lld ",i);printf("\n");
    return 0;
}