#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define bit(n,m)((n>>m)&1)

ll dp[1<<20];
int cnt[1<<20];
int idx[1<<20];

int c(const void*p,const void*q){
	if(cnt[*(int*)p]<cnt[*(int*)q])return -1;
	if(cnt[*(int*)p]>cnt[*(int*)q])return  1;
	if(dp[*(int*)p]<dp[*(int*)q])return -1;
	return 1;
}

int bs(int c,ll x,int num){
	//dp[l]<x<=dp[r]
	int l=0,r=num;
	if(c<cnt[idx[0]]||c==cnt[idx[0]]&&x<=dp[idx[0]])return 0;
	while(r-l>1){
		int m=(l+r)/2;
		if(c<cnt[idx[m]]||c==cnt[idx[m]]&&x<=dp[idx[m]])r=m;
		else l=m;
	}
	return r;
}


ll a[40];
int main(){
	int n,k;
	ll l,r;
	scanf("%d%d%lld%lld",&n,&k,&l,&r);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	int N=n-n/2;
	n/=2;
	for(int i=0;i<1<<n;i++){
		for(int k=0;k<n;k++)if(bit(i,k)){
			dp[i]+=a[k];
			cnt[i]++;
		}
		idx[i]=i;
	}
	qsort(idx,1<<n,sizeof(int),c);
	ll ans=0;
	for(int i=0;i<1<<N;i++){
		ll s=0;
		int temp=0;
		for(int k=0;k<N;k++)if(bit(i,k)){
			s+=a[n+k];
			temp++;
		}
		ans+=bs(k-temp,r+1-s,1<<n)-bs(k-temp,l-s,1<<n);
	}
	printf("%lld\n",ans);
}
