import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn._

object Main extends App {
  val Array(_n, _k, l, r) = readLine.trim.split(' ').map(_.toLong)
  val n = _n.toInt
  val k = _k.toInt
  val coin = readLine.trim.split(' ').map(_.toLong)
  val prev = Array.fill(k + 1){ArrayBuffer[Long]()}
  for (p ← 0 until (1 << (n / 2))) {
    var sum = 0L
    var count = 0
    for (i ← 0 until n / 2) {
      if ((p & (1 << i)) != 0) {
        sum += coin(i)
        count += 1
      }
    }
    if (count < prev.length) prev(count).append(sum)
  }
  val post = Array.fill(k + 1){ArrayBuffer[Long]()}
  for (p ← 0 until (1 << (n - n / 2))) {
    var sum = 0L
    var count = 0
    for (i ← 0 until (n - n / 2)) {
      if ((p & (1 << i)) != 0){
        sum += coin(i + n / 2)
        count += 1
      }
    }
    if (count < post.length) post(count).append(sum)
  }
  prev.indices.foreach(i ⇒ prev(i) = prev(i).sorted)
  post.indices.foreach(i ⇒ post(i) = post(i).sorted)
  var sum = 0L
  for (i ← 0 to k) {
    for (p ← prev(i)) {
      sum += upperBound(post(k - i), r - p) - lowerBound(post(k - i), l - p)
    }
  }
  println(sum)
  def lowerBound(array: ArrayBuffer[Long], target: Long): Int = {
    var left = 0
    var right = array.length
    while (left < right) {
      val mid = (left + right) / 2
      if (array(mid) < target) left = mid + 1
      else right = mid
    }
    right
  }
  def upperBound(array: ArrayBuffer[Long], target: Long): Int = {
    var left = 0
    var right = array.length
    while (left < right) {
      val mid = (left + right) / 2
      if (array(mid) <= target) left = mid + 1
      else right = mid
    }
    right
  }
}
