#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ll INF = 1e15;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b == 1) {
		return a;
	}
	ll ans = pow(a, b / 2);
	ans *= ans;
	ans *= b % 2 == 1 ? a : 1;
	return ans;
}

namespace SOLVE {
	void add(VLL &A, vector<VLL> &countsA, ll index, ll count, ll coinscounted) {
		count += index < 0 ? 0 : A[index];
		coinscounted++;
		countsA[coinscounted].push_back(count);
		
		ll n = sz(A);
		REP(i, index + 1, n) {
			add(A, countsA, i, count, coinscounted);
		}
	}

	ll lowerBound(VLL &A, ll l, ll r, ll number) { // first index that is larger or equal to number
		// A is sorted
		ll m = (l + r) / 2;
		if (l == r) {
			if (A[l] >= number) {
				return l;
			}
			return -1;
		}
		if (A[m] < number) {
			return lowerBound(A, m + 1, r, number);
		}
		else {
			return lowerBound(A, l, m, number);
		}
	}

	ll upperBound(VLL &A, ll l, ll r, ll number) { // last index that is smaller than number
		// A is sorted
		ll m = (l + r) / 2 + 1;
		if (l == r) {
			if (A[l] <= number) {
				return l;
			}
			return -1;
		}
		if (A[m] <= number) {
			return upperBound(A, m, r, number);
		}
		else {
			return upperBound(A, l, m - 1, number);
		}
	}


	void main() {
		ll N, K, L, R, temp;
		VLL A, B;
		vector<VLL> countsA, countsB;
		cin >> N >> K >> L >> R;

		REP(i, 0, N / 2) {
			cin >> temp;
			A.push_back(temp);
		}
		REP(i, N / 2, N) {
			cin >> temp;
			B.push_back(temp);
		}
		countsA.resize(sz(A) + 1);
		countsB.resize(sz(B) + 1);
		add(A, countsA, -1, 0, -1);
		add(B, countsB, -1, 0, -1);

		ll ans = 0;
		REP(fromA, 0, sz(countsA)) { // coins from A
			ll fromB = K - fromA; // coins from B
			if (fromB >= sz(countsB) || fromB < 0) {
				continue;
			}
			sort(countsB[fromB].begin(), countsB[fromB].end()); // sort B
			
			for (ll numberA : countsA[fromA]) { // for every number in A
				// cout << numberA << endl;

				ll Bright = R - numberA;
				ll Bleft = L - numberA;
				ll lb = lowerBound(countsB[fromB], 0, sz(countsB[fromB]) - 1, Bleft);
				ll ub = upperBound(countsB[fromB], 0, sz(countsB[fromB]) - 1, Bright);
				
				/*
				for (auto a : countsB[fromB]) {
					cout << a << ' ';
				} cout << endl;
				cout << Bleft << ' ' << Bright << endl;
				cout << lb << ' ' << ub << endl;
				*/

				if (lb == -1 || ub == -1) {
					continue;
				}
				ans += (ub - lb + 1);
				// cout << ans << endl;
			}
		}
		cout << ans << endl;

	}
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}



Measured memory_bytes: 23388