n, k, l, r = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
sum = a.inject(:+)
if k > n / 2
  k = n - k
  l, r = sum - r, sum - l
end
b = a[0..n/2]
c = a[n/2+1..-1]

hb = (0..b.size).map { Hash.new(0) }
hb[0][0] = 1
subset_sum = Array.new(2**b.size, 0)
one_count = Array.new(2**b.size, 0)
(1..2**b.size-1).each do |x|
  i = Math.log2((x ^ (x - 1)) + 1).to_i - 1
  y = x & (x - 1)
  subset_sum[x] = subset_sum[y] + b[i]
  one_count[x] = one_count[y] + 1
  hb[one_count[x]][subset_sum[x]] += 1
end

hc = (0..c.size).map { Hash.new(0) }
hc[0][0] = 1
subset_sum = Array.new(2**c.size, 0)
one_count = Array.new(2**c.size, 0)
(1..2**c.size-1).each do |x|
  i = Math.log2((x ^ (x - 1)) + 1).to_i - 1
  y = x & (x - 1)
  subset_sum[x] = subset_sum[y] + c[i]
  one_count[x] = one_count[y] + 1
  hc[one_count[x]][subset_sum[x]] += 1
end

answer = 0
(0..k).each do |m|
  next if !hb[m] || !hc[k - m]
  keys1 = hb[m].keys.sort
  keys2 = hc[k - m].keys.sort
  count_accum = [0]
  keys2.each {|x| count_accum << count_accum[-1] + hc[k - m][x] }

  keys1.each do |x|
    break if x > r
    i = (0..keys2.size-1).bsearch {|i| l <= x + keys2[i] } || keys2.size
    j = ((0..keys2.size-1).bsearch {|j| r <  x + keys2[j] } || keys2.size) - 1
    answer += hb[m][x] * (count_accum[j + 1] - count_accum[i])
  end
end
p answer

