#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n, k;
    ll l, r;
    cin >> n >> k >> l >> r;
    ll a[n];
    rep (i, 0, n) cin >> a[i];

    vector<vector<ll>> L (k + 1), R (k + 1);
    for (int bit = 0; bit < (1 << (n / 2)); bit++) {
        ll sum = 0;
        if (__builtin_popcount (bit) > k) continue;
        for (int i = 0; i < n / 2; i++) {
            if (bit & (1 << i)) {
                sum += a[i];
            }
        }
        L[__builtin_popcount (bit)].push_back (sum);
    }
    rep (i, 0, k + 1) {
        sort (L[i].begin(), L[i].end());
        // cout << L[i].size() << "\n";
    }
    for (int bit = 0; bit < (1 << (n - n / 2)); bit++) {
        ll sum = 0;
        if (__builtin_popcount (bit) > k) continue;
        for (int i = 0; i < n - n / 2; i++) {
            if (bit & (1 << i)) {
                sum += a[n / 2 + i];
            }
        }
        R[__builtin_popcount (bit)].push_back (sum);
    }
    ll ans = 0;
    rep (i, 0, k + 1) {
        rep (j, 0, R[i].size()) {
            if (R[i][j] > r) continue;
            ll sum =
                upper_bound (L[k - i].begin(), L[k - i].end(), r - R[i][j]) -
                lower_bound (L[k - i].begin(), L[k - i].end(), l - R[i][j]);
            ans += sum;
        }
    }
    cout << ans << "\n";
}
