#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void loop (i64 *a, i32 n, i32 k, i64 *res, i32 *len) {
  static i64 val = 0;
  if (k == 0) {
    res[(*len)++] = val;
    return;
  }
  if (n < k) return;
  val += a[0];
  loop (a + 1, n - 1, k - 1, res, len);
  val -= a[0];
  loop (a + 1, n - 1, k, res, len);
  return;
}

int cmp (const void *a, const void *b) {
  i64 d = *(i64 *)a - *(i64 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

i64 calc (i64 *a, i32 alen, i64 *b, i32 blen, i64 lim) {
  i64 res = 0;
  i32 j = 0;
  for (i32 i = alen - 1; i >= 0; --i) {
    while (j < blen && a[i] + b[j] <= lim) j++;
    res += j;
  }
  return res;
}

void run (void) {
  i32 n, k;
  i64 l, r;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi64 "%" SCNi64, &n, &k, &l, &r);
  i64 *a = (i64 *) calloc (n, sizeof (i64));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi64,a + i);
  }
  i64 ans = 0;
  i32 m = n / 2;
  i64 *front = (i64 *) calloc (184756, sizeof (i64));
  i64 *back = (i64 *) calloc (184756, sizeof (i64));
  for (i32 i = 0; i <= k; ++i) {
    i32 front_len = 0;
    loop (a, m, i, front, &front_len);
    i32 back_len = 0;
    loop (a + m, n - m, k - i, back, &back_len);
    qsort (front, front_len, sizeof (i64), cmp);
    qsort (back, back_len, sizeof (i64), cmp);
    ans += calc (front, front_len, back, back_len, r);
    ans -= calc (front, front_len, back, back_len, l - 1);
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}

