#include<bits/stdc++.h>
#define RG register
#define il inline
#define LL long long
#define N 20000005
using namespace std;
int rs[N],ls[N],rt[N],tree[N],n,k,L,R,aa;LL sum[500001],id;
#define mid ((l+r)>>1)
void Insert(int y,int & x,LL l,LL r,LL val){
x=++id;tree[x]=tree[y]+1;rs[x]=rs[y],ls[x]=ls[y];if(l==r)return;
if(mid<val)Insert(rs[y],rs[x],mid+1,r,val);
else Insert(ls[y],ls[x],l,mid,val);
}
LL Query(int y,int x,LL l,LL r,LL val){
if(l==r)return l;int tmp=tree[ls[x]]-tree[ls[y]];
if(tree[x]-tree[y]<val)return 1e9;
if(tmp<val)return Query(rs[y],rs[x],mid+1,r,val-tmp);
else return Query(ls[y],ls[x],l,mid,val);
}
struct node{
int pos,rnk;LL val;
bool operator < (const node & a) const{return val<a.val;}
};LL Ans;
#define lll -500001000
#define rrr 500001000
priority_queue<node>hp;
int main(){
scanf("%d%d%d%d",&n,&k,&L,&R);Insert(0,rt[0],lll,rrr,0);
for(int i=1;i<=n;++i)scanf("%d",&aa),sum[i]=sum[i-1]+aa;
for(int i=1;i<=n;++i)Insert(rt[i-1],rt[i],lll,rrr,sum[i]);
for(int l=L;l<=n;++l){int ri=l-L,le=l-R-1;
LL x;if(le<0)x=Query(0,rt[ri],lll,rrr,1);
else x=Query(rt[le],rt[ri],lll,rrr,1);
hp.push((node){l,1,sum[l]-x});
}while(k--){
node tmp=hp.top();hp.pop();
int l=tmp.pos,ri=l-L,le=l-R-1,rnk=tmp.rnk;
LL x;if(le<0)x=Query(0,rt[ri],lll,rrr,rnk+1);
else x=Query(rt[le],rt[ri],lll,rrr,rnk+1);Ans+=tmp.val;
hp.push((node){l,rnk+1,sum[l]-x});
}printf("%lld\n",Ans);
return 0;
}