You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made.

A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest must be at least l and at most r. Also, you think that the difference between difficulties of the easiest and the hardest of the chosen problems must be at least x.

Find the number of ways to choose a problemset for the contest.


-----Input-----

The first line contains four integers n, l, r, x (1 ≤ n ≤ 15, 1 ≤ l ≤ r ≤ 10^9, 1 ≤ x ≤ 10^6) — the number of problems you have, the minimum and maximum value of total difficulty of the problemset and the minimum difference in difficulty between the hardest problem in the pack and the easiest one, respectively.

The second line contains n integers c_1, c_2, ..., c_{n} (1 ≤ c_{i} ≤ 10^6) — the difficulty of each problem.


-----Output-----

Print the number of ways to choose a suitable problemset for the contest. 


-----Examples-----
Input
3 5 6 1
1 2 3

Output
2

Input
4 40 50 10
10 20 30 25

Output
2

Input
5 25 35 10
10 10 20 10 20

Output
6



-----Note-----

In the first example two sets are suitable, one consisting of the second and third problem, another one consisting of all three problems.

In the second example, two sets of problems are suitable — the set of problems with difficulties 10 and 30 as well as the set of problems with difficulties 20 and 30.

In the third example any set consisting of one problem of difficulty 10 and one problem of difficulty 20 is suitable.

Source: codeforces | Difficulty: MEDIUM
Tags: Bit manipulation

Complete search


Solutions:
(n, l, r, x) = map(int, input().split())
lis = list(map(int, input().split()))
sol = 0
for i in range(3, 1 << n):
	mini = float('Inf')
	maxi = -float('Inf')
	tot = 0
	for j in range(n):
		if 1 << j & i != 0:
			mini = min(lis[j], mini)
			maxi = max(lis[j], maxi)
			tot += lis[j]
	if tot >= l and tot <= r and (maxi - mini >= x):
		sol += 1
print(sol)


ans = 0
(n, l, w, x) = map(int, input().split())

def printCombination(arr, n, r):
	data = [0] * r
	combinationUtil(arr, data, 0, n - 1, 0, r)

def combinationUtil(arr, data, start, end, index, r):
	if index == r:
		if l <= sum(data) <= w and max(data) - min(data) >= x:
			global ans
			ans += 1
		return
	i = start
	while i <= end and end - i + 1 >= r - index:
		data[index] = arr[i]
		combinationUtil(arr, data, i + 1, end, index + 1, r)
		i += 1
arr = list(map(int, input().split()))
for r in range(2, n + 1):
	n = len(arr)
	printCombination(arr, n, r)
print(ans)


(n, l, r, x) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
cnt = 0
for i in range(0, 1 << n):
	sum = 0
	mn = int(1e+18)
	mx = 0
	for j in range(0, n):
		if i >> j & 1:
			sum += a[j]
			mn = min(mn, a[j])
			mx = max(mx, a[j])
	if sum >= l and sum <= r and (mx - mn >= x):
		cnt += 1
print(cnt)


def dfs(now, num, l, r, dx, c):
	if now < 0 or num >= r:
		return 0
	temp = dfs(now - 1, num, l, r, dx, c)
	num += c[now]
	if num >= l and num <= r and (c[now] <= dx):
		temp += 1
	return temp + dfs(now - 1, num, l, r, dx, c)
c = input().split()
n = int(c[0])
l = int(c[1])
r = int(c[2])
x = int(c[3])
c = input().split()
for i in range(n):
	c[i] = int(c[i])
c.sort()
ans = 0
for i in range(1, n):
	if c[0] + x > c[i]:
		continue
	ans += dfs(i - 1, c[i], l, r, c[i] - x, c)
print(ans)


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
qtd = 0
for b in range(int('1' * n, base=2) + 1):
	binary = bin(b)[2:]
	binary = '{:0>{n}}'.format(int(binary), n=n)
	vetor = []
	for (i, d) in enumerate(binary):
		if d == '1':
			vetor.append(c[i])
	vetor.sort()
	if l <= sum(vetor) <= r and vetor[-1] - vetor[0] >= x:
		qtd += 1
print(qtd)


(n, l, r, x) = map(int, input().strip().split())
c = [int(v) for v in input().strip().split()]
ans = 0
for mask in range(1, 1 << n):
	cur = 0
	mn = max(c)
	mx = min(c)
	for j in range(n):
		if mask & 1 << j > 0:
			cur += c[j]
			mn = min(mn, c[j])
			mx = max(mx, c[j])
	if cur >= l and cur <= r and (mx - mn >= x):
		ans += 1
print(ans)


(n, l, r, x) = list(map(int, input().split(' ')))
c = sorted(list(map(int, input().split(' '))))
ways = 0
for i in range(0, 2 ** n):
	temp = 0
	m = 10 ** 9 + 1
	M = -1
	for j in range(0, n):
		if i & 1 << j:
			temp += c[j]
			m = min(m, c[j])
			M = max(M, c[j])
	if temp >= l and temp <= r and (M - m >= x):
		ways += 1
print(ways)


def isValid(arr, l, r, x):
	return l <= sum(arr) <= r and max(arr) - min(arr) >= x
(n, l, r, x) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
valid = 0
for i in range(1, 1 << n):
	s = str(bin(i))[2:].rjust(n, '0')
	temp = []
	for j in range(n):
		if s[j] == '1':
			temp.append(arr[j])
	if isValid(temp, l, r, x):
		valid += 1
print(valid)


(n, l, r, x) = map(int, input().split())
cs = list(map(int, input().split()))

def subsets(x):
	if len(x) == 0:
		return [[]]
	a = subsets(x[1:])
	b = [[x[0]] + c for c in a]
	return a + b
sets = subsets(cs)
ans = 0
for s in sets:
	if len(s) < 2:
		continue
	if not l <= sum(s) <= r:
		continue
	if max(s) - min(s) < x:
		continue
	ans += 1
print(ans)


def GSB(x):
	counter = 0
	while x != 0:
		counter += 1
		x = x >> 1
	return counter
(problems, minimum, maximum, difference) = [int(x) for x in input().split()]
array = [int(x) for x in input().split()]
combinations = [int(x) for x in range(2 ** problems)]
total = 0
for i in combinations:
	checker = [x for x in array] + ['a']
	j = 0
	z = GSB(i)
	check = 1
	while j != z and i != 0:
		if i & 1 == 1:
			checker[j] = 'a'
			check += 1
		i = i >> 1
		j += 1
	for i in range(check):
		checker.remove('a')
	checker.sort()
	if minimum <= sum(checker) <= maximum and len(checker) >= 2 and (checker[-1] - checker[0] >= difference):
		total += 1
print(total)


from collections import deque
from math import ceil, floor, sqrt, gcd

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def si():
	return input()
(n, l, r, x) = mi()
a = li()
c = 0
for i in range(pow(2, n)):
	x1 = bin(i)
	x1 = x1[2:]
	y = n - len(x1)
	x1 = '0' * y + x1
	s = 0
	y2 = 0
	y1 = 1000005
	np = 0
	for j in range(n):
		if x1[j] == '1':
			s += a[j]
			np += 1
			y1 = min(y1, a[j])
			y2 = max(y2, a[j])
	if np >= 2 and s >= l and (s <= r) and (y2 - y1 >= x):
		c += 1
print(c)


from itertools import chain, combinations

def powerset(iterable):
	s = list(iterable)
	return chain.from_iterable((combinations(s, r) for r in range(len(s) + 1)))
(N, L, R, X) = map(int, input().split(' '))
C = map(int, input().split(' '))

def is_ok(c):
	if len(c) < 2:
		return False
	if not L <= sum(c) <= R:
		return False
	if max(c) - min(c) < X:
		return False
	return True
print(sum([1 for c in powerset(C) if is_ok(c)]))


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
res = 0
for i in range(1 << n):
	Bit = []
	for j in range(n):
		if i & 1 << j:
			Bit.append(c[j])
	if len(Bit) >= 2 and l <= sum(Bit) <= r and (max(Bit) - min(Bit) >= x):
		res += 1
print(res)


import itertools

def read_data():
	(n, l, r, x) = map(int, input().split())
	cs = list(map(int, input().split()))
	return (n, l, r, x, cs)

def solve(n, l, r, x, cs):
	cs.sort()
	count = 0
	for m in range(2, n + 1):
		for sets in itertools.combinations(cs, m):
			diff = sets[-1] - sets[0]
			if diff < x:
				continue
			sumsets = sum(sets)
			if sumsets < l or sumsets > r:
				continue
			count += 1
	return count
(n, l, r, x, cs) = read_data()
print(solve(n, l, r, x, cs))


import itertools
(n, l, r, x) = list(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
if len(C) > 1:
	for i in range(2, len(C) + 1):
		for j in itertools.combinations(C, i):
			if l <= sum(j) <= r and max(j) - min(j) >= x:
				ans += 1
print(ans)


from itertools import combinations
(n, l, r, x) = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(2, n + 1):
	for c in combinations(C, i):
		s = sum(c)
		if s < l or r < s:
			continue
		if max(c) - min(c) < x:
			continue
		ans += 1
print(ans)


(n, lower, upper, x) = map(int, input().split())
c = sorted(map(int, input().split()))
result = 0
for mask in range(3, 1 << n):
	s = 0
	a = None
	for i in range(n):
		if mask & 1 << i:
			s += c[i]
			if a is None:
				a = c[i]
			b = c[i]
	if lower <= s <= upper and b - a >= x:
		result += 1
print(result)


from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
cnt = 0
for i in range(2 ** n):
	var = 0
	t = 0
	h = 0
	m = 10 ** 6
	for j in range(n):
		if i & 1 << j:
			t += arr[j]
			h = max(h, arr[j])
			m = min(m, arr[j])
			var += 1
	if t >= l and t <= r and (h - m >= x) and (var >= 2):
		cnt += 1
print(cnt)


def mlt():
	return map(int, input().split())
(x, l, r, df) = mlt()
s = sorted(list(mlt()))

def f(x):
	global s, l, r, df
	tm = []
	for n in range(len(s)):
		if x % 2:
			tm.append(s[n])
		x //= 2
	return int(sum(tm) >= l and sum(tm) <= r and (max(tm) - min(tm) >= df))
res = 0
for n in range(1 << x):
	res += f(n)
print(res)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
sys.setrecursionlimit(111111)
INF = 99999999999999999999999999999999

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, l, r, x) = ria()
		a = sorted(ria())
		ans = 0
		for i in range(2 ** n):
			k = bin(i)[2:]
			k = '0' * (n - len(k)) + k
			z = []
			sz = 0
			for j in range(n):
				if k[j] == '1':
					z.append(a[j])
					sz += a[j]
			if len(z) >= 2 and l <= sz <= r and (z[-1] - z[0] >= x):
				ans += 1
		wi(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from itertools import combinations
(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
result = sum([sum([max(j) - min(j) >= x and l <= sum(j) <= r for j in combinations(a, i)]) for i in range(2, n + 1)])
print(result)


(n, l, r, x) = [int(x) for x in input().split(' ')]
arr = [int(x) for x in input().split(' ')]
ans = 0
for i in range(2 ** n):
	subset = []
	for j in range(n):
		if i & 1 << j != 0:
			subset.append(arr[j])
	if len(subset) > 1:
		mx = max(subset)
		mn = min(subset)
		sm = sum(subset)
		if l <= sm <= r and mx - mn >= x:
			ans += 1
print(ans)


from sys import stdin
inp = lambda : stdin.readline().strip()

def int2bin(integer, digits):
	if integer >= 0:
		return bin(integer)[2:].zfill(digits)
	else:
		return bin(2 ** digits + integer)[2:]
(n, l, r, x) = [int(x) for x in inp().split()]
a = [int(x) for x in inp().split()]
ans = 0
for i in range(2 ** n):
	s = int2bin(i, n)
	total = 0
	minimum = float('inf')
	maximum = -1
	for j in range(n):
		if s[j] == '1':
			total += a[j]
			minimum = min(minimum, a[j])
			maximum = max(maximum, a[j])
	if l <= total <= r and maximum - minimum >= x:
		ans += 1
print(ans)


(n, l, r, x) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
mask = (1 << n) - 1
ans = 0
for sub in range(mask + 1):
	(s, num) = (0, 0)
	(hard, easy) = (float('-inf'), float('inf'))
	for i in range(n):
		if sub & 1 << i > 0:
			s += a[i]
			num += 1
			hard = max(a[i], hard)
			easy = min(a[i], easy)
	if s >= l and s <= r and (hard - easy >= x) and (num >= 2):
		ans += 1
print(ans)


from itertools import *
(n, l, r, x) = map(lambda x: int(x), input().split())
c = sorted(list(map(lambda x: int(x), input().split())))
variants = []
for i in range(2, n + 1):
	variants.extend(list(combinations(c, i)))
counter = 0
for i in range(len(variants)):
	sum_var = sum(variants[i])
	if sum_var >= l and sum_var <= r and (variants[i][-1] - variants[i][0] >= x):
		counter += 1
print(counter)


(n, l, r, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
subsets = []
for i in range(1, 2 ** n):
	temp = []
	for j in range(n):
		if 1 << j & i:
			temp.append(a[j])
	subsets.append(temp)
count = 0
for i in range(len(subsets)):
	cur = subsets[i]
	mi = min(cur)
	ma = max(cur)
	if ma - mi >= x:
		s = sum(cur)
		if s >= l and s <= r:
			count += 1
print(count)


from itertools import *

def powerset(iterable):
	s = list(iterable)
	return chain.from_iterable((combinations(s, r) for r in range(len(s) + 1)))

def solve(c, l, r, x):
	res = 0
	for ss in powerset(c):
		if len(ss) >= 2 and l <= sum(ss) <= r and (max(ss) - min(ss) >= x):
			res += 1
	return res
assert solve([1, 2, 3], 5, 6, 1) == 2
assert solve([10, 20, 30, 25], 40, 50, 10) == 2
assert solve([10, 10, 20, 10, 20], 25, 35, 10) == 6
(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
print(solve(c, l, r, x))


from itertools import combinations

def main():
	(n, l, r, x) = [int(t) for t in input().split()]
	c = [int(t) for t in input().split()]

	def is_valid(candidate):
		mx = max(candidate)
		mn = min(candidate)
		sm = sum(candidate)
		return l <= sm <= r and mx - mn >= x
	way = 0
	for L in range(2, len(c) + 1):
		for subset in combinations(c, L):
			if is_valid(subset):
				way += 1
	print(way)
main()


import itertools
criteria = input()
items_weights = input()
(n, m, k, p) = map(int, criteria.split())
_items_weights = list(map(int, items_weights.split()))
if not 1 <= n <= 15 or not 1 <= m <= k <= 10 ** 9 or (not 1 <= p <= 10 ** 6) or (not n == len(_items_weights)):
	print('ошибка ввода данных')
	exit(1)

def is_ok(m, k, p, items):
	return m <= sum(items) <= k and max(items) - min(items) >= p
answer = 0
for r in range(n):
	tmp = itertools.combinations(_items_weights, r=r + 1)
	for el in tmp:
		if is_ok(m, k, p, el):
			answer += 1
print(answer)


from sys import stdin, stdout
import bisect as bs
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))

def fn(mask):
	mn = r + 1
	mx = 0
	sm = 0
	for i in range(n):
		if mask >> i & 1:
			mn = min(mn, a[i])
			mx = max(mx, a[i])
			sm += a[i]
	if l <= sm <= r and mx - mn >= x:
		return True
	return False
for _ in range(1):
	(n, l, r, x) = lst()
	a = lst()
	ans = 0
	for mask in range(1 << n):
		if fn(mask):
			ans += 1
	print(ans)


(N, L, H, d) = map(int, input().split())
l = list(map(int, input().split()))
e = 0
for i in range(1 << N):
	k = []
	for j in range(N):
		if i >> j & 1:
			k.append(l[j])
	if len(k) > 0:
		maz = max(k)
		mins = min(k)
		sums = sum(k)
		if sums >= L and sums <= H:
			if maz - mins >= d:
				e += 1
print(e)


import sys
mod = 1000000007

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, l, r, x) = get_ints()
Arr = get_array()
ans = 0
for i in range(1 << n):
	B = []
	for j in range(n):
		if i >> j & 1:
			B.append(Arr[j])
	if len(B) >= 2 and l <= sum(B) <= r and (max(B) - min(B) >= x):
		ans += 1
print(ans)


def combine(n, k, w=1, out=[], result=[]):
	if k == 0:
		result.append(out)
	for i in range(w, n + 1):
		new_out = out[:]
		new_out.append(i)
		combine(n, k - 1, i + 1, new_out)
	return result

def main():
	(n, l, r, x) = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	if n < 2:
		print(0)
		return
	result = None
	for i in range(2, n + 1):
		if i == n:
			result = combine(n, i)
		else:
			combine(n, i)
	for i in range(len(result)):
		comb = result[i]
		for j in range(len(comb)):
			comb[j] = c[comb[j] - 1]
	cnt = 0
	for i in range(len(result)):
		sm = sum(result[i])
		if sm >= l and sm <= r and (max(result[i]) - min(result[i]) >= x):
			cnt += 1
	print(cnt)
main()


(n, l, r, x) = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = 0
for i in range(1, 1 << n):
	a = []
	s = 0
	for j in range(0, n):
		if i >> j & 1 > 0:
			a.append(c[j])
			s += c[j]
	a.sort()
	if s >= l and s <= r and (a[len(a) - 1] - a[0] >= x):
		ans = ans + 1
print(ans)


from itertools import combinations
(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
answer = 0
for i in range(1, n + 1):
	for j in combinations(arr, i):
		if len(j) >= 2 and l <= sum(j) <= r and (max(j) - min(j) >= x):
			answer += 1
print(answer)


import math, string, itertools, fractions, heapq, collections, re, array, bisect
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict, deque

def VI():
	return list(map(int, input().split()))

def main(n, l, r, x, c):
	all = []
	for i in range(1, n + 1):
		com = combinations(c, i)
		for j in com:
			s = sum(j)
			if s >= l and s <= r and (max(j) - min(j) >= x):
				all.append(j)
	print(len(all))

def main_input(info=0):
	(n, l, r, x) = VI()
	c = VI()
	main(n, l, r, x, c)
main_input()

def test():
	(n, l, r, x) = (15, 1, 100000, 1)
	c = list(range(15))
	main(n, l, r, x, c)


import itertools
(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
cnt = 0
for i in range(2, n + 1):
	combinations = itertools.combinations(c, i)
	for comb in combinations:
		max_ = 0
		min_ = 10 ** 6
		sum_ = 0
		for co in comb:
			sum_ += co
			if co > max_:
				max_ = co
			if co < min_:
				min_ = co
		cnt += 1 if l <= sum_ <= r and max_ - min_ >= x else 0
print(cnt)


aa = 0
(a, b, c, d) = list(map(int, input().split(' ')))
l = list(map(int, input().split(' ')))
for i in range(2 ** a):
	k = bin(i)[2:]
	t = 0
	k = '0' * (a - len(k)) + k
	x = []
	for j in range(a):
		if k[j] == '1':
			x.append(l[j])
			t += 1
	if t >= 2:
		if b <= sum(x) <= c and max(x) - min(x) >= d:
			aa += 1
print(aa)


(n, least, most, x) = map(int, input().split())
c = list(map(int, input().split()))
ans = 0
_max = lambda x, y: x if x > y else y
_min = lambda x, y: x if x < y else y
for mask in range(1 << n):
	mx = float('-inf')
	mn = float('inf')
	count = 0
	Sum = 0
	for i in range(n):
		if mask & 1 << i:
			count += 1
			Sum += c[i]
			mx = _max(mx, c[i])
			mn = _min(mn, c[i])
	if mx - mn >= x and Sum >= least and (Sum <= most) and (count >= 2):
		ans += 1
print(ans)


def s():
	[n, l, r, x] = list(map(int, input().split(' ')))
	l -= 1
	r += 1
	a = list(map(int, input().split(' ')))

	def f(i=0, s=0, mi=10 ** 6, ma=1):
		if i == n:
			return ma - mi >= x and l < s < r
		return f(i + 1, s + a[i], min(mi, a[i]), max(ma, a[i])) + f(i + 1, s, mi, ma)
	print(f())
s()


from itertools import combinations

def combos(lst):
	for i in range(0, len(lst)):
		for combo in combinations(lst, i + 1):
			yield combo
inp = list(map(int, input().split()))
n = inp[0]
l = inp[1]
r = inp[2]
k = inp[3]
probs = sorted(list(map(int, input().split())))
count = 0
for sublist in combos(probs):
	if sublist[len(sublist) - 1] - sublist[0] >= k:
		s = sum(sublist)
		if s >= l and s <= r:
			count += 1
print(count)


import sys
import string
from collections import defaultdict
from functools import lru_cache
from collections import Counter

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def subsets(arr):
	if len(arr) == 0:
		return [([], float('inf'), -float('inf'), 0)]
	else:
		rest = subsets(arr[1:])
		all_subsets = []
		for (subset, minn, maxx, summ) in rest:
			all_subsets.append((subset, minn, maxx, summ))
			comb = subset + [arr[0]]
			if arr[0] > maxx:
				maxx = arr[0]
			if arr[0] < minn:
				minn = arr[0]
			all_subsets.append((comb, minn, maxx, summ + arr[0]))
		return all_subsets

def main(arr, l, r, x):
	c = 0
	for (subset, minn, maxx, summ) in subsets(arr):
		if summ >= l and summ <= r and (maxx - minn >= x):
			c += 1
	print(c)
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		(_, l, r, x) = mi(line)
	else:
		arr = lmi(line)
main(arr, l, r, x)


import sys
import math
import bisect
import math
from itertools import accumulate
from itertools import combinations
import string
input = sys.stdin.readline

def inpit():
	return int(input())

def inplt():
	return list(map(int, input().split()))

def inpstr():
	s = input()
	return list(s[:len(s) - 1])

def inpspit():
	return map(int, input().split())
pow = math.pow
fl = math.floor
ceil = math.ceil
dis = math.hypot

def lcm(a):
	return abs(math.prod(a)) // math.gcd(*a)

def cumulativeSum(input):
	return list(accumulate(input))

def all_set(string):
	lt = []
	for i in range(0, len(string) + 1):
		for element in combinations(string, i):
			lt.append(element)
	return lt

def dfs(p, j, g):
	for i in g[p]:
		if i == j:
			return True
	return False
(n, l, r, x) = inpspit()
lt = all_set(inplt())
a = 0
for i in lt:
	if l <= sum(i) <= r and max(i) - min(i) >= x:
		a = a + 1
print(a)


c = 0

def backtracking(actuales, restantes, l, r, x):
	global c
	if sum(actuales) <= r and sum(actuales) >= l:
		if max(actuales) - min(actuales) >= x:
			c += 1
	if restantes:
		for i in range(len(restantes)):
			backtracking(actuales + [restantes[i]], restantes[i + 1:], l, r, x)
	return 0

def main():
	(n, l, r, x) = input().split(' ')
	(n, l, r, x) = (int(n), int(l), int(r), int(x))
	difficulties = input().split(' ')
	for i in range(len(difficulties)):
		difficulties[i] = int(difficulties[i])
	difficulties.sort()
	backtracking([], difficulties, l, r, x)
	global c
	return c
print(main())


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(sys.stdin.readline())

def In():
	return map(int, sys.stdin.readline().split())

def Sn():
	return sys.stdin.readline().strip()

def Pr(x):
	sys.stdout.write(str(x) + '\n')

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gte(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def check(i, a):
	s = bin(i)[2:]
	s = s[::-1]
	if len(s) > len(a):
		return False
	(mn, mx) = (P, -1)
	cost = 0
	for i in range(len(s)):
		if s[i] == '1':
			mn = min(mn, a[i])
			mx = max(mx, a[i])
			cost += a[i]
	if cost >= l and cost <= r and (mx - mn >= x) and (s.count('1') > 1):
		return True
	return False

def main():
	try:
		global l, r, x
		(n, l, r, x) = In()
		a = list(In())
		a.sort()
		cnt = 0
		for i in range(1, 2 ** n + 1):
			if check(i, a):
				cnt += 1
		print(cnt)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


def test(a, b, C, s, n, l, r, x, p):
	if C == []:
		if s >= l and s <= r and (b - a >= x):
			return 1
		return 0
	if s >= l and s <= r and (b - a >= x):
		acc = 1
	else:
		acc = 0
	for i in range(len(C)):
		if s + C[i] <= r:
			acc += test(min(a, C[i]), max(b, C[i]), C[i + 1:], s + C[i], n, l, r, x, p + [C[i]])
	return acc
import time
(n, l, r, x) = (int(i) for i in input().split())
C = sorted([int(i) for i in input().split()])
start = time.time()
acc = 0
for i in range(len(C)):
	acc += test(C[i], C[i], C[i + 1:], C[i], n, l, r, x, [C[i]])
print(acc)
finish = time.time()


(n, l, r, x) = [int(x) for x in input().split()]
vals = [int(x) for x in input().split()]
opts = 0
for v in range(2 ** n):
	curr = []
	for i in range(n):
		if v & 2 ** i:
			curr.append(vals[i])
	if l <= sum(curr) <= r and max(curr) - min(curr) >= x:
		opts += 1
print(opts)


from itertools import combinations
(n, l, r, x) = map(int, input().split())
(*a,) = map(int, input().split())
sumu = 0
for i in range(2, n + 2):
	for j in combinations(a, i):
		if r >= sum(j) >= l and max(j) - min(j) >= x:
			sumu += 1
print(sumu)


def read():
	return map(int, input().split())
(n, l, r, x) = read()
c = list(read())
ans = 0
for i in range(2 ** n):
	cfg = bin(i)[2:].zfill(n)
	if cfg.count('1') > 1:
		nums = [d for (j, d) in enumerate(c) if cfg[j] == '1']
		if max(nums) - min(nums) >= x and l <= sum(nums) <= r:
			ans += 1
print(ans)


s = input().split(' ')
(n, l, r, d) = [int(x) for x in s]
arr = input().split(' ')
arr = [int(x) for x in arr]
arr.sort()
ans = 0
for x in range(2 ** n + 1):
	m = 0
	sum = 0
	t = x
	for i in range(n):
		if t % 2 == 1:
			if m == 0:
				m = arr[i]
			sum += arr[i]
			M = arr[i]
		t = t // 2
	if sum <= r and sum >= l and (M - m >= d):
		ans += 1
print(ans)


from itertools import combinations
(n, l, r, x) = map(int, input().split())
problems = [int(x) for x in input().split()]
ans = 0
for i in range(2, n + 1):
	for comb in combinations(problems, i):
		isum = sum(comb)
		imin = min(comb)
		imax = max(comb)
		if l <= isum <= r and imax - imin >= x:
			ans += 1
print(ans)


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
from bisect import bisect_left

def check(temp):
	if len(temp) < 2:
		return False
	else:
		s = sum(temp)
		if s >= l and s <= r:
			if temp[-1] - temp[0] >= x:
				return True
			else:
				return False
		else:
			return False

def brute(index, temp):
	global count
	if index == n:
		if check(temp):
			count += 1
	else:
		temp.append(arr[index])
		brute(index + 1, temp)
		temp.pop()
		brute(index + 1, temp)
(n, l, r, x) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
arr.sort()
count = 0
temp = []
brute(0, temp)
print(count)


def find(a, b):
	cc = 2
	for i in range(1, 1 << len(a)):
		sx = 0
		minn = 100000000
		maxn = -1
		for j in range(0, len(a)):
			if i & 1 << j:
				sx += a[j]
				minn = min(minn, a[j])
				maxn = max(maxn, a[j])
		if sx >= b[1] and sx <= b[2] and (maxn - minn >= b[3]):
			cc += 1
	if cc < 2:
		return 2
	else:
		return cc - 2
b = list(map(int, input().split()))
a = list(map(int, input().split()))
print(find(a, b))


R = lambda : list(map(int, input().split()))
(n, l, r, x) = R()
c = R()
ans = 0
for mask in range(1 << n):
	(sum, mini, maxi, cnt) = (0, 1000000000.0, -1000000000.0, 0)
	for i in range(n):
		if mask & 1 << i:
			sum += c[i]
			mini = min(mini, c[i])
			maxi = max(maxi, c[i])
			cnt += 1
	if maxi - mini >= x and l <= sum <= r and (cnt > 1):
		ans += 1
print(ans)


vet = []
aux = []
cont = 0

def fa(i, f):
	global aux, cont
	if i <= f:
		aux.append(vet[i])
		if len(aux) >= 2 and menor <= sum(aux) <= maior and (max(aux) - min(aux) >= diff):
			cont += 1
		for k in range(i, f):
			fa(k + 1, f)
		aux.pop()
(n, menor, maior, diff) = map(int, input().split())
vet = list(map(int, input().split()))
for i in range(n):
	fa(i, n - 1)
print(cont)


from itertools import combinations as cmb
(n, l, r, x) = map(int, input().split())
(*a,) = map(int, input().split())
b = []
a.sort()
for i in range(2, n + 1):
	b.extend(cmb(a, i))
ans = 0
for i in b:
	if sum(i) >= l and sum(i) <= r:
		if i[-1] - i[0] >= x:
			ans += 1
print(ans)


def main():
	(n, l, r, x) = map(int, input().split())
	(cc, res) = (sorted(map(int, input().split())), 0)
	for i in range(1, 2 ** n):
		(tmp, idx) = ([], 0)
		while i:
			if i & 1:
				tmp.append(cc[idx])
			idx += 1
			i >>= 1
		if tmp[-1] - tmp[0] >= x and l <= sum(tmp) <= r:
			res += 1
	print(res)
main()


from itertools import *
(n, x, y, q) = map(int, input().split())
l = list(map(int, input().split()))
d = []
c = 0
for i in range(1, n + 1):
	p = combinations(l, i)
	for ii in p:
		d.append(list(ii))
for i in range(len(d)):
	s = sum(d[i])
	if (s >= x and s <= y) and max(d[i]) - min(d[i]) >= q:
		c += 1
print(c)


from itertools import combinations
(n, l, r, x) = input().split()
n = int(n)
l = int(l)
r = int(r)
x = int(x)
c = []
cc = input().split()
for i in range(n):
	cc[i] = int(cc[i])
	c.append(cc[i])
c2 = []
for i in range(len(c) + 1):
	c2.append([x for x in combinations(c, i)])
k = 0
for i in range(len(c2)):
	for j in range(len(c2[i])):
		if sum(c2[i][j]) >= l and sum(c2[i][j]) <= r and (max(c2[i][j]) - min(c2[i][j]) >= x):
			k += 1
print(k)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n, l, r, x) = I()
a = I()
ans = 0
for i in range(1, 2 ** n):
	if i & i - 1 == 0:
		continue
	(mn, mx, total) = (INF, -INF, 0)
	for j in range(n):
		if i >> j & 1:
			mn = min(mn, a[j])
			mx = max(mx, a[j])
			total += a[j]
	if l <= total <= r and mx - mn >= x:
		ans += 1
print(ans)


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
cnt = 0

def f(i, total, mx, mn, num):
	global cnt
	if i == n:
		if l <= total <= r and mx - mn >= x and (num >= 2):
			cnt += 1
		return
	f(i + 1, total + c[i], max(mx, c[i]), min(mn, c[i]), num + 1)
	f(i + 1, total, mx, mn, num)
f(0, 0, 0, 99999999999, 0)
print(cnt)


import sys
import math
import bisect
from math import sqrt

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
ans = 0

def f(c, ind, li):
	global ans
	if ind == len(c):
		if len(li) >= 2 and li[-1] - li[0] >= x and (l <= sum(li) <= r):
			ans += 1
		return
	f(c, ind + 1, li)
	f(c, ind + 1, li + [c[ind]])
(n, l, r, x) = rinput()
c = get_list()
c.sort()
f(c, 0, [])
print(ans)


def suma_o_resta(a, b):
	return a & 1 << b

def diferencia(s1, d):
	if s1:
		s1.sort()
		if s1[-1] - s1[0] >= d:
			return s1
		else:
			return diferencia(s1.remove(s1[-1]), d)
	return s1

def no_sets(v, n, l, r, d):
	s = []
	cont = 0
	for x in range(1 << n):
		for i in range(n):
			if suma_o_resta(x, i) > 0:
				s.append(v[i])
		s = diferencia(s, d)
		if s:
			if sum(s) >= l and sum(s) <= r:
				cont += 1
		s = []
	return cont
(n, l, r, x) = map(int, input().split())
v = list(map(int, input().split()))
print(str(no_sets(v, n, l, r, x)))


(n, l, r, d) = [int(i) for i in input().split()]
op = [int(i) for i in input().split()]
c = 0
for i in range(2, 2 ** n):
	s = 0
	k = 0
	maxx = 0
	minn = 1000001
	x = bin(i)[2:]
	x = '0' * (n - len(x)) + x
	for j in range(n):
		if x[j] == '1':
			s += op[j]
			k += 1
			if maxx < op[j]:
				maxx = op[j]
			if op[j] < minn:
				minn = op[j]
	if l <= s <= r and maxx - minn >= d and (k >= 2):
		c += 1
print(c)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj
import sys
import threading
from math import *
for _ in range(1):
	(n, l, r, x) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt = 0
	for mask in range(1, (1 << n) + 1):
		mini = 10 ** 9 + 10
		maxi = 0
		elem = 0
		sumi = 0
		for j in range(n):
			if mask & 1 << j:
				elem += 1
				sumi += a[j]
				mini = min(mini, a[j])
				maxi = max(maxi, a[j])
		if elem >= 2:
			if l <= sumi <= r and maxi - mini >= x:
				cnt += 1
	print(cnt)


import math as mt
import itertools as it
(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for j in range(2, n + 1):
	for i in it.combinations(a, j):
		if max(i) - min(i) >= x and l <= sum(i) <= r:
			ans += 1
print(ans)


print((lambda go, n, l, r, x, a: go(go, 0, n, l, r, x, a, 0, 10 ** 9, -1))(lambda self, i, n, l, r, x, a, s, mi, ma: int(l <= s <= r and ma - mi >= x) if i >= n else self(self, i + 1, n, l, r, x, a, s, mi, ma) + self(self, i + 1, n, l, r, x, a, s + a[i], min(mi, a[i]), max(ma, a[i])), *map(int, input().split()), list(map(int, input().split()))))


(n, l, r, x) = map(int, input().split())
a = input().split()
ran = 2 ** n
answer = 0
for i in range(n):
	a[i] = int(a[i])
for i in range(ran):
	m = i
	mask = ''
	while m != 0:
		if m % 2 == 0:
			mask += '0'
		else:
			mask += '1'
		m = m // 2
	while len(mask) < n:
		mask += '0'
	s = 0
	easy = 10 ** 9 + 100
	hard = 0
	for j in range(len(mask)):
		if mask[j] == '1':
			if a[j] >= hard:
				hard = a[j]
			if a[j] <= easy:
				easy = a[j]
			s += a[j]
	if s <= r and s >= l and (hard - easy >= x):
		answer += 1
print(answer)


(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in range(2 ** n):
	maxc = -1
	minc = -1
	c = 0
	for j in range(n):
		if i >> j & 1 == 1:
			c += a[j]
			maxc = max(maxc, a[j])
			if minc == -1:
				minc = a[j]
			else:
				minc = min(a[j], minc)
	if c >= l and c <= r and (maxc - minc >= x):
		count += 1
print(count)


(n, l, r, x) = tuple(map(int, input().split()))
cs = sorted(list(map(int, input().split())))

def findSet(s, minc, maxc, depth, rest, left, n, l, r, x):
	if s > r or (left >= n and s < l):
		return 0
	ans = 0
	if s >= l and s <= r and (depth >= 2) and (minc + x <= maxc):
		ans = 1
	for i in range(left, n):
		c = rest[i]
		if minc == 0:
			ans += findSet(s + c, c, c, depth + 1, rest, i + 1, n, l, r, x)
		else:
			ans += findSet(s + c, minc, c, depth + 1, rest, i + 1, n, l, r, x)
	return ans
print(findSet(0, 0, 0, 0, cs, 0, n, l, r, x))


(n, l, r, x) = map(int, input().split())
c = [int(x) for x in input().split()]
ans = 0
i = 0
maxval = 0
minval = 0
sum = 0
while i < 1 << n:
	maxval = -1
	minval = 1000000
	sum = 0
	for j in range(n):
		if i & 1 << j:
			sum += c[j]
			maxval = max(maxval, c[j])
			minval = min(minval, c[j])
	if l <= sum and sum <= r and (maxval - minval >= x):
		ans += 1
	i += 1
print(ans)


(n, l, r, x) = map(int, input().split(' '))
c = list(map(int, input().split()))
count = 0
for num in range(1 << n):
	v = [c[i] for i in range(n) if num & 1 << i > 0]
	if sum(v) <= r and sum(v) >= l:
		if max(v) - min(v) >= x:
			count = count + 1
print(count)


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
from itertools import combinations
ways_to_choose = 0
for length in range(2, n + 1):
	for p in combinations(c, length):
		problemset = sorted(p)
		if l <= sum(problemset) <= r and problemset[-1] - problemset[0] >= x:
			ways_to_choose += 1
print(ways_to_choose)


def solve():
	(n, l, r, x) = map(int, input().split(' '))
	c = list(map(int, input().split(' ')))
	ans = 0
	for bitmask in range(2 ** n):
		if bin(bitmask).count('1') > 1:
			(res, _min, _max) = (0, float('+inf'), float('-inf'))
			for (c_i, bit_i) in zip(c, (1 & int(bitmask) >> i for i in range(n))):
				if bit_i:
					res += c_i * bit_i
					if c_i < _min:
						_min = c_i
					if c_i > _max:
						_max = c_i
			if l <= res <= r and _max - _min >= x:
				ans += 1
	print(ans)
solve()


(n, l, r, x) = map(int, input().split())
difficulties = list(map(int, input().split()))
total = 0
mask = 0
while mask < 1 << n:
	difficulty_sum = 0
	turns = 0
	easy = 0
	hard = 0
	for i in range(n):
		if mask & 1 << i:
			difficulty_sum += difficulties[i]
			turns += 1
			if not easy or not hard:
				if not easy:
					easy = difficulties[i]
				if not hard:
					hard = difficulties[i]
			elif difficulties[i] < easy:
				easy = difficulties[i]
			elif difficulties[i] > hard:
				hard = difficulties[i]
	if l <= difficulty_sum <= r and hard - easy >= x and (turns > 1):
		total += 1
	mask += 1
print(total)


cnt = 0

def condition(arr, l, r, x):
	if not arr:
		return False
	s = sum(arr)
	ma = max(arr)
	mi = min(arr)
	if s <= r and s >= l and (ma - mi >= x):
		return True
	return False

def dp(i, n, st, arr, l, r, x):
	global cnt
	if i == n:
		result = []
		for i in range(len(st)):
			if st[i] == '1':
				result.append(arr[i])
		if condition(result, l, r, x):
			cnt += 1
		return
	dp(i + 1, n, st + '0', arr, l, r, x)
	dp(i + 1, n, st + '1', arr, l, r, x)

def main():
	(n, l, r, x) = [int(t) for t in input().split(' ')]
	arr = [int(t) for t in input().split(' ')]
	dp(0, n, '', arr, l, r, x)
	print(cnt)
main()


(n, l, r, x) = map(int, input().split())
C = sorted(list(map(int, input().split())))
ANS = 0
for i in range(2 ** n):
	s = bin(i)[2:]
	s = '0' * (n - len(s)) + s
	L = []
	for j in range(n):
		if s[j] == '1':
			L.append(C[j])
	if len(L) < 2 or not l <= sum(L) <= r or L[-1] - L[0] < x:
		continue
	ANS += 1
print(ANS)


import itertools
q = 0
(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
for j in range(2, n + 1):
	for i in itertools.combinations(c, j):
		if l <= sum(i) <= r and max(i) - min(i) >= x:
			q += 1
print(q)


nlrx = list(map(int, input().split()))
(n, l, r, x) = nlrx
problems = list(map(int, input().split()))
valid_sets = []
numSets = pow(2, n)
for i in range(1, numSets):
	currSet = []
	for j in range(n):
		if i & 1 << j > 0:
			currSet.append(problems[j])
	if sum(currSet) < l or sum(currSet) > r:
		continue
	elif not max(currSet) - min(currSet) >= x:
		continue
	valid_sets.append(currSet)
print(len(valid_sets))


I = lambda : map(int, input().split())
(n, l, r, x) = I()
(C, k) = ([*I()], 0)
for i in range(2 ** n):
	W = [w for (w, b) in zip(C, bin(i)[2:].zfill(n)) if b == '1']
	if l <= sum(W) <= r and max(W) - min(W) >= x:
		k += 1
print(k)


import sys

def set(mask, pos):
	return mask | 1 << pos

def isOn(mask, pos):
	return mask & 1 << pos > 0
(n, l, r, x) = map(int, input().split(' '))
dif = list(map(int, input().split(' ')))
(count, mask) = (0, 0)
while mask <= 2 ** n:
	(summ, bit) = ([], 0)
	while bit < n:
		if isOn(mask, bit):
			summ.append(dif[bit])
		bit += 1
	if sum(summ) <= r and sum(summ) >= l and (max(summ) - min(summ) >= x):
		count += 1
	mask += 1
print(count)


def b_f(l_v, c_v, c_i, l, h, l_p, h_p, x):
	if c_i == len(l_v):
		return 0
	else:
		n_l = l_v[c_i] if not l_p else min(l_v[c_i], l_p)
		n_h = l_v[c_i] if not l_p else max(l_v[c_i], h_p)
		return (1 if c_v + l_v[c_i] >= l and c_v + l_v[c_i] <= h and (n_h - n_l >= x) else 0) + (b_f(l_v, c_v, c_i + 1, l, h, l_p, h_p, x) + b_f(l_v, c_v + l_v[c_i], c_i + 1, l, h, n_l, n_h, x))
(n, l, r, x) = map(int, input().split())
l_v = list(map(int, input().split()))
print(b_f(l_v, 0, 0, l, r, None, None, x))


from sys import stdin
from itertools import combinations
(n, l, r, x) = map(int, stdin.readline().rstrip().split(' '))
li = list(map(int, stdin.readline().rstrip().split(' ')))
z = []
ans = 0
for i in range(2, n + 1):
	z += list(combinations(li, i))
for i in z:
	a = sorted(i)
	if a[-1] - a[0] >= x and r >= sum(a) >= l:
		ans += 1
print(ans)


def main():
	mode = 'fil'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[n, l, r, x] = get()
	c = get()
	if n == 1:
		print('0')
		return
	c.sort()
	if c[-1] - c[0] < x:
		print('0')
		return
	count = 0
	for i in range(3, 1 << n):
		mm = list(str(bin(i))[2:])
		if mm.count('1') < 2:
			continue
		hold = i
		mm.reverse()
		temp = []
		for j in range(len(mm)):
			if mm[j] == '1':
				temp.append(c[j])
		if temp[-1] - temp[0] < x:
			continue
		s = sum(temp)
		if s >= l and s <= r:
			count += 1
	print(count)
	if mode == 'file':
		f.close()
main()


ways = 0

def solve(i, l, r, x, max1, min1, sum, flag):
	global ways
	if flag == 0:
		if max1 != min1 and (max1 != -99999999999999 and min1 != 99999999999999):
			if sum > r:
				return
			elif sum >= l and max1 - min1 >= x:
				ways += 1
	if i < 0:
		return
	solve(i - 1, l, r, x, max(max1, a[i]), min(min1, a[i]), sum + a[i], 0)
	solve(i - 1, l, r, x, max1, min1, sum, 1)
(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
solve(n - 1, l, r, x, -99999999999999, 99999999999999, 0, 0)
print(ways)


import itertools
import math
from collections import defaultdict

def input_ints():
	return list(map(int, input().split()))

def solve():
	(n, l, r, d) = input_ints()
	c = input_ints()

	def check(x):
		return len(x) >= 2 and l <= sum(x) <= r and (max(x) - min(x) >= d)
	ans = 0
	for mask in range(1 << n):
		b = [mask >> i & 1 for i in range(n)]
		x = list(itertools.compress(c, b))
		if check(x):
			ans += 1
	print(ans)
solve()


def gray(n):
	if n == 1:
		return ['0', '1']
	l1 = gray(n - 1)
	l2 = reversed(l1)
	l1 = [a + '0' for a in l1]
	l2 = [a + '1' for a in l2]
	return l1 + l2
(n, l, r, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
ps = gray(n)
ans = 0
for i in ps:
	ma = -1
	mi = 10000000
	s = 0
	k = 0
	for j in range(n):
		if i[j] == '1':
			k += 1
			s += a[j]
			mi = min(mi, a[j])
			ma = max(ma, a[j])
	if s >= l and s <= r and (ma - mi >= x) and (k > 1):
		ans += 1
print(ans)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(n, l, r, x) = int_array()
a = sorted(int_array())
ans = 0
for mask in range(1 << n):
	mx = NINF
	mn = INF
	sub = 0
	for i in range(n):
		if 1 << i & mask:
			sub += a[i]
			mx = max(mx, a[i])
			mn = min(mn, a[i])
	if sub >= l and sub <= r:
		if mx - mn >= x:
			ans += 1
print(ans)


import itertools
(n, l, r, x) = [int(c) for c in input().split()]
c = [int(c) for c in input().split()]
c.sort()
count = 0
for i in range(2, n + 1):
	combs = itertools.combinations(c, i)
	for comb in combs:
		min = comb[0]
		max = comb[0]
		sum = 0
		for a in comb:
			sum += a
			if a > max:
				max = a
			if a < min:
				min = a
		if sum >= l and sum <= r and (max - min >= x):
			count += 1
print(count)


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
ans = 0
for i in range(0, 2 ** n):
	v = []
	for j in range(n):
		if i & 1 << j:
			v.append(c[j])
	if sum(v) >= l and sum(v) <= r and (max(v) - min(v) >= x):
		ans += 1
print(ans)


a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
n = a[0]
l = a[1]
r = a[2]
x = a[3]
ans = 0
puis = 1 << n
for m in range(puis):
	mn = 1000000
	mx = 1
	cnt = 0
	sum = 0
	for i in range(n):
		if m & 1 << i != 0:
			cnt += 1
			sum += b[i]
			mn = min(mn, b[i])
			mx = max(mx, b[i])
	if mx - mn >= x and sum >= l and (sum <= r) and (cnt >= 2):
		ans += 1
print(ans)


import itertools
(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
res = 0
for sz in range(1, n + 1):
	for c in itertools.combinations(a, sz):
		s = sum(c)
		ma = max(c)
		mi = min(c)
		if l <= s <= r and ma - mi >= x:
			res += 1
print(res)


def inp():
	return map(int, input().split())

def arr_inp():
	return [int(x) for x in input().split()]
from itertools import *
(n, l, r, x) = inp()
(c, out) = (arr_inp(), 0)
for i in range(2, n + 1):
	for j in list(combinations(c, i)):
		(s, mi, ma) = (sum(j), min(j), max(j))
		if s >= l and s <= r and (ma - mi >= x):
			out += 1
print(out)


from sys import stdin, stdout

def read():
	return stdin.readline().rstrip()

def readint():
	return int(read())

def readints():
	return [int(i) for i in read().split()]
(_, l, r, x) = readints()
xs = sorted(readints())
total = 0
for i in range(1 << len(xs)):
	ans = [xs[moves] for moves in range(len(xs)) if i & 1 << moves]
	if not ans:
		continue
	seq = ans[-1] - ans[0] >= x
	if l <= sum(ans) <= r and len(ans) > 1 and seq:
		total += 1
print(total)


(n, l, r, x) = map(int, input().split())
C = list(map(int, input().split()))
C.sort()
z = 0
for i in range(2 ** n):
	b = bin(i)[2:]
	while len(b) < n:
		b = '0' + b
	S = 0
	D = []
	for j in range(len(b)):
		if b[j] == '1':
			S = S + C[j]
			D.append(C[j])
	if S >= l and S <= r and (max(D) - min(D) >= x) and (len(D) > 1):
		z = z + 1
print(z)


def calcular_problemas(n, l, r, x, problemas):
	num_elementos = n
	conj_act = 0
	num_formas = 0
	while conj_act < 1 << num_elementos:
		suma_de_problemas = 0
		pos_max_enc = 0
		pos_min_dif = 0
		pos_max_dif = 0
		contar_elementos = 0
		for elemento in range(num_elementos):
			if conj_act & 1 << elemento != 0 and pos_max_enc == 0:
				pos_max_dif = elemento
				pos_max_enc = 1
			if conj_act & 1 << elemento != 0 and pos_max_enc != 0:
				pos_min_dif = elemento
			if conj_act & 1 << elemento != 0:
				contar_elementos += 1
				suma_de_problemas += problemas[elemento]
				if suma_de_problemas > r:
					break
		if suma_de_problemas <= r and suma_de_problemas >= l and (problemas[pos_max_dif] - problemas[pos_min_dif] >= x) and (contar_elementos >= 2):
			num_formas += 1
		conj_act += 1
	return num_formas
parametros = input()
problemas = input()
parametros = parametros.split(' ')
parametros = list(map(lambda x: int(x), parametros))
problemas = problemas.split(' ')
problemas = list(map(lambda x: int(x), problemas))
problemas.sort(reverse=True)
print(calcular_problemas(*parametros, problemas))


from itertools import combinations
(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
c = []
for i in range(2, n + 1):
	c += list(combinations(a, i))
cnt = 0
for t in c:
	m = min(t)
	M = max(t)
	s = sum(t)
	if M - m >= x and (s >= l and s <= r):
		cnt += 1
print(cnt)


def rec(c, at, mark, l, r, x, _max, _min, _sum):
	if _sum > r:
		return 0
	res = 0
	if _max - _min >= x and _sum >= l and (_sum <= r):
		res += 1
	for i in range(at, len(c)):
		if mark[i]:
			continue
		res += rec(c, i + 1, mark, l, r, x, max(_max, c[i]), min(_min, c[i]), _sum + c[i])
	return res
(n, l, r, x) = [int(v) for v in input().split(' ')]
c = [int(i) for i in input().split(' ')]
mark = [False for i in range(n)]
res = 0
for i in range(n):
	mark[i] = True
	res += rec(c, i, mark, l, r, x, c[i], c[i], c[i])
print(res)


def subsets(S):
	sets = []
	len_S = len(S)
	for i in range(1 << len_S):
		subset = [S[bit] for bit in range(len_S) if i & 1 << bit]
		sets.append(subset)
	return sets
(n, l, r, x) = list(map(int, input().split()))
problems = list(map(int, input().split()))
res = 0
for m in subsets(problems):
	if l <= sum(m) <= r and max(m) - min(m) >= x:
		res += 1
print(res)


def gen(n):
	if n == 1:
		yield '0'
		yield '1'
	else:
		for s in gen(n - 1):
			yield (s + '0')
			yield (s + '1')
(n, l, r, x) = map(int, input().split())
cnt = 0
C = list(map(int, input().split()))
for pos in gen(n):
	A = []
	for i in range(n):
		if pos[i] == '1':
			A.append(C[i])
	A.sort()
	if len(A):
		if l <= sum(A) <= r and A[-1] - A[0] >= x:
			cnt += 1
print(cnt)


(n, l, r, x) = map(int, input().split())
m = list(map(int, input().split()))
res = 0
for i in range(3, int(1 << n)):
	if str(bin(i)).count('1') > 1:
		s = bin(i)[2:].zfill(n)
		mi = 1000000000.0 + 1
		ma = 0
		su = 0
		for (j, e) in enumerate(s):
			if e == '1':
				su += m[j]
				mi = min(mi, m[j])
				ma = max(ma, m[j])
		if l <= su <= r and ma - mi >= x:
			res += 1
print(res)


(n, l, r, x) = map(int, input().split())
li = list(map(int, input().split()))
t = (1 << n) - 1
ans = 0
while t != 0:
	(s, mi, mx) = (0, 1000001, 0)
	for i in range(len(li)):
		if t & 1 << i:
			s += li[i]
			mi = min(mi, li[i])
			mx = max(mx, li[i])
	if mx - mi >= x and (s >= l and s <= r):
		ans += 1
	t -= 1
print(ans)


__author__ = 'victormion'
import itertools

def function():
	res = 0
	for i in range(2, len(vet) + 1):
		temp = itertools.combinations(vet, i)
		for case in temp:
			sum = 0
			minimum = None
			maximum = None
			for j in case:
				sum += int(j)
				val = int(j)
				if minimum == None or val < minimum:
					minimum = val
				if maximum == None or val > maximum:
					maximum = val
			if sum >= l and sum <= r and (maximum - minimum >= x):
				res += 1
	return res
(n, l, r, x) = input().strip().split()
(n, l, r, x) = (int(n), int(l), int(r), int(x))
vet = input().strip().split()
print(function())


import math
(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
d = [0] * (n + 1)
answer = 0
while d[-1] != 1:
	e = []
	for i in range(n):
		if d[i]:
			e.append(c[i])
	if sum(e) >= l and sum(e) <= r:
		if len(e) >= 2:
			if e[-1] - e[0] >= x:
				answer += 1
	d[0] += 1
	for i in range(n):
		if d[i] == 2:
			d[i] = 0
			d[i + 1] += 1
		else:
			break
print(answer)


(n, l, r, x) = list(map(int, input().split()))
c = list(map(int, input().split()))
from itertools import combinations
ans = 0
for i in range(2, len(c) + 1):
	all = combinations(c, i)
	for j in all:
		sum = 0
		mn = 10000000
		mx = 0
		for k in j:
			mn = min(mn, k)
			mx = max(mx, k)
			sum += k
		if sum >= l and sum <= r and (mx - mn >= x):
			ans += 1
print(ans)


from itertools import combinations
(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
count = 0
for i in range(2, n + 1):
	for p in combinations(c, i):
		if l <= sum(p) <= r and max(p) - min(p) >= x:
			count += 1
print(count)


def GETBIT(x, bit):
	return x >> bit & 1
(n, l, r, dif) = map(int, input().split())
a = list(map(int, input().split()))
rs = 0
for i in range(1, 1 << n):
	lst = []
	for j in range(n):
		if GETBIT(i, j) == 1:
			lst.append(a[j])
	if max(lst) - min(lst) >= dif:
		if sum(lst) >= l and sum(lst) <= r:
			rs += 1
print(rs)


(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
count = 0
for mask in range(0, 1 << n):
	max_total = 0
	min_total = 0
	diff = 0
	temp_arr = []
	for i in range(n):
		if mask & 1 << i:
			temp_arr.append(arr[i])
	if l <= sum(temp_arr) <= r and max(temp_arr) - min(temp_arr) >= x and (len(temp_arr) >= 2):
		count += 1
print(count)


from itertools import combinations
(n, mn, mx, diff) = map(int, input().split())
arr = list(map(int, input().split()))
cnt = 0
for i in range(2, n + 1):
	cnt += sum((1 for x in combinations(arr, i) if sum(x) >= mn and sum(x) <= mx and (max(x) - min(x) >= diff)))
print(cnt)


from itertools import combinations

def is_valid(diffs):
	if sum(diffs) > r or sum(diffs) < l or diffs[-1] - diffs[0] < x:
		return False
	return True
(n, l, r, x) = (int(i) for i in input().split())
d = sorted([int(i) for i in input().split()])
ind = {i for i in range(n)}
nvalid = 0
for numel in range(n + 1):
	for subset in combinations(ind, numel):
		diffs = [d[i] for i in subset]
		if is_valid(diffs):
			nvalid += 1
print(nvalid)


from collections import defaultdict, deque, Counter, OrderedDict

def main():
	(n, l, r, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	ans = 0
	for i in range(1 << n):
		(cmin, cmax, ctot) = (10000000000.0, 0, 0)
		for j in range(n):
			if i & 1 << j:
				(cmin, cmax, ctot) = (min(cmin, a[j]), max(cmax, a[j]), ctot + a[j])
		if r >= ctot >= l and cmax - cmin >= x:
			ans += 1
	print(ans)
main()


from itertools import combinations
(p, minn, maxn, dif) = map(int, input().split())
(*lst,) = map(int, input().split())
c = 0
for i in range(2, p + 2):
	for j in combinations(lst, i):
		if maxn >= sum(j) >= minn and max(j) - min(j) >= dif:
			c += 1
print(c)


from itertools import combinations
(a, b, c, d) = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
fl = []
for i in range(2, a + 1):
	tl = list((list(e) for e in combinations(l, i)))
	for e in tl:
		fl.append(e)
for e in fl:
	n = len(e)
	e = sorted(e)
	t = 0
	if max(e) - min(e) >= d:
		pass
	else:
		t = 1
	if t == 0 and len(e) >= 2:
		s = sum(e)
		if s >= b and s <= c:
			ans = ans + 1
print(ans)


def subsets(L, i):
	if i == len(L):
		yield []
	else:
		for s in subsets(L, i + 1):
			yield s
			yield ([L[i]] + s)

def computeValidProblemsets(problems, l, r, x):
	isValid = lambda ps: len(ps) > 1 and l <= sum(ps) <= r and (ps[-1] - ps[0] >= x)
	print(sum((isValid(problemset) for problemset in subsets(sorted(problems), 0))))
(n, l, r, x) = map(int, input().split())
problems = list(map(int, input().split()))
computeValidProblemsets(problems, l, r, x)


def isValidSet(problemSet: list, minTotalDif: int, maxTotalDif: int, minDelta: int) -> bool:
	if len(problemSet) >= 2:
		total = sum(problemSet)
		myDelta = max(problemSet) - min(problemSet)
		if minTotalDif <= total <= maxTotalDif and myDelta >= minDelta:
			return True
	return False

def countValidSubsets(problems: list, minTotalDif: int, maxTotalDif: int, minDelta: int) -> int:

	def subsetBuilder(problems: list, currentSubset: list, nextElementIndex: int) -> None:
		if isValidSet(currentSubset, minTotalDif, maxTotalDif, minDelta):
			validSubsets.append(currentSubset)
		for i in range(nextElementIndex, len(problems)):
			currentSubset.append(problems[i])
			subsetBuilder(problems, currentSubset, i + 1)
			currentSubset.pop(-1)
	index = 0
	currentSubset = []
	validSubsets = []
	subsetBuilder(problems, currentSubset, index)
	return len(validSubsets)
(n, l, r, x) = input().split()
n = int(n)
l = int(l)
r = int(r)
x = int(x)
probs = [int(prob) for prob in input().split()]
print(countValidSubsets(probs, l, r, x))


(n, l, r, x) = list(map(int, input().split()))
s = list(map(int, input().split()))
olmps = []
c = []
v = 0
for i in range(1 << n):
	olmps.append([])
	for j in range(n):
		if i & 1 << j:
			olmps[-1].append(s[j])
for o in olmps:
	if l <= sum(o) <= r:
		c.append(o)
for z in c:
	if max(z) - min(z) >= x:
		v += 1
print(v)


ans = 0
(n, l, r, x) = map(int, input().split())
z = list(map(int, input().split()))
for i in range(3, 1 << len(z)):
	lst = []
	for j in range(25):
		if i & 1 << j:
			lst.append(z[j])
	lst.sort()
	if len(lst) > 1 and l <= sum(lst) <= r and (lst[-1] - lst[0] >= x):
		ans += 1
print(ans)


import sys
input = []
input_index = 0

def next(type, number=None):

	def next():
		global input, input_index
		while input_index == len(input):
			if sys.stdin:
				input = sys.stdin.readline().split()
				input_index = 0
			else:
				raise Exception()
		input_index += 1
		return input[input_index - 1]
	if number is None:
		result = type(next())
	else:
		result = [type(next()) for _ in range(number)]
	return result

def fac(a):
	return 1 if a <= 1 else fac(a - 1) * a
(n, l, r, x) = next(int, 4)
cs = next(int, n)
cs = sorted(cs)
groups = [[]]
for c in cs:
	new_groups = []
	for group in groups:
		new_groups.append(group)
		new_groups.append(group + [c])
	groups = new_groups
counter = 0
for group in groups:
	if len(group) >= 2:
		if group[-1] - group[0] >= x:
			if l <= sum(group) <= r:
				counter += 1
print(counter)


(n, l, r, x) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list()
total = 0
for i in range(1, 1 << n):
	for j in range(0, n):
		if i & 1 << j != 0:
			b.append(a[j])
	if len(b) >= 2:
		if sum(b) >= l and sum(b) <= r and (max(b) - min(b) >= x):
			total = total + 1
	b = list()
print(total)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	(n, l, r, x) = LI()
	a = sorted(LI())
	rr = 0
	for i in range(n):
		for j in range(i + 1, n):
			if a[j] - a[i] < x:
				continue
			d = collections.defaultdict(int)
			d[0] = 1
			for c in a[i + 1:j]:
				for (k, v) in list(d.items()):
					d[k + c] += v
			t = l - a[j] - a[i]
			u = r - a[j] - a[i]
			for (k, v) in d.items():
				if t <= k <= u:
					rr += v
	return rr
print(main())


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
from math import gcd
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())

def check_in_subset(b, i):
	k = b & 1 << i
	if k == 0:
		return False
	return True

def generate_subsequences(arr, l, r, x):
	n = len(arr)
	ans = 0
	for i in range(1 << n):
		difficulty = 0
		lowest = float('inf')
		highest = 0
		for j in range(n):
			if check_in_subset(i, j):
				difficulty += arr[j]
				lowest = min(lowest, arr[j])
				highest = max(highest, arr[j])
		if highest - lowest >= x and l <= difficulty <= r:
			ans += 1
	return ans
(n, l, r, x) = inp()
c = inp()
print(generate_subsequences(c, l, r, x))


import itertools
(n, l, r, x) = map(int, input().split())
problems = [int(x) for x in input().split()]
result = 0
for i in range(2, n + 1):
	for comb in itertools.combinations(problems, i):
		summ = sum(comb)
		mini = min(comb)
		maxx = max(comb)
		if l <= summ <= r and maxx - mini >= x:
			result += 1
print(result)


def solve(n, l, r, x, L):
	res = 0

	def inner(a):
		p_list = []
		tl = 0
		for i in range(n):
			if 1 << i & a == 0:
				p_list.append(L[i])
				tl += L[i]
		p_list.sort()
		if tl >= l and tl <= r and (p_list[-1] - p_list[0] >= x) and (len(p_list) > 1):
			return True
		return False
	for i in range(1, 2 ** n + 1):
		if inner(i):
			res += 1
	return res
(n, l, r, x) = map(int, input().split())
L = list(map(int, input().split()))
print(solve(n, l, r, x, L))


l = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
l2 = sorted(l2)
ans = 0
for i in range(1 << l[0]):
	first = -1
	last = -1
	t = 0
	for j in range(l[0]):
		if 1 << j & i > 0:
			if first == -1:
				first = j
			last = j
			t += l2[j]
	if l2[last] - l2[first] >= l[3] and t >= l[1] and (t <= l[2]):
		ans += 1
print(ans)


(n, l, r, x) = map(int, input().split())
num = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	st = bin(i)[2:]
	st = '0' * (n - len(st)) + st
	if st.count('1') >= 2:
		pt = []
		for i in range(len(st)):
			if st[i] == '1':
				pt.append(num[i])
		if sum(pt) <= r and sum(pt) >= l and (max(pt) - min(pt) >= x):
			ans += 1
print(ans)


res = 0
(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
msk = 1
while msk <= 1 << n:
	mn = 1 << 31
	mx = -1
	sum = 0
	cnt = 0
	for y in range(0, n):
		if msk & 1 << y:
			cnt += 1
			sum += a[y]
			mx = max(mx, a[y])
			mn = min(mn, a[y])
	res += mx - mn >= x and sum >= l and (sum <= r) and (cnt > 1)
	msk = msk + 1
print(res)


(n, l, r, x) = map(int, input().split())
a = [int(i) for i in input().split()]
count = 0
for i in range(1, 2 ** n + 1):
	temp = []
	for j in range(n):
		if i & 1 << j:
			temp.append(a[j])
	if len(temp) and max(temp) - min(temp) >= x and (sum(temp) >= l) and (sum(temp) <= r):
		count += 1
print(count)


def combinations(arr, n):
	if n == 0:
		return [[]]
	l = []
	for i in range(len(arr)):
		m = arr[i]
		rem = arr[i + 1:]
		for j in combinations(rem, n - 1):
			l.append([m] + j)
	return l

def solve(arr, n, l, r, x):
	subset = []
	for i in range(2, n + 1):
		for j in combinations(arr, i):
			if sum(j) >= l and sum(j) <= r:
				subset.append(j)
	count = 0
	for i in subset:
		mn = min(i)
		mx = max(i)
		if mx - mn >= x:
			count += 1
	return count
(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
print(solve(arr, n, l, r, x))


import sys
(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
res = 0
for i in range(1, 2 ** n):
	s = 0
	mn = 10 ** 7
	mx = -1
	for j in range(0, n):
		if i >> j & 1 == 1:
			t = c[j]
			s += t
			mn = min(mn, t)
			mx = max(mx, t)
	if l <= s and s <= r and (mx - mn >= x):
		res += 1
print(res)


import itertools
(n, l, r, x) = map(int, input().split())
a = [int(i) for i in input().split()]
count = 0
s = sum(a)
if s >= l and s <= r and (max(a) - min(a) >= x):
	count += 1
for i in range(2, n):
	b = list(itertools.combinations(a, i))
	for j in range(0, len(b)):
		s = sum(b[j])
		if s >= l and s <= r and (max(b[j]) - min(b[j]) >= x):
			count += 1
print(count)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
from itertools import combinations
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, l, r, x) = iia()
arr = iia()
count = 0
for i in range(2, n + 1):
	t = combinations(arr, i)
	for j in t:
		if sum(j) >= l and sum(j) <= r and (max(j) - min(j) >= x):
			count += 1
print(count)


def check(j):
	if sum(j) >= l and sum(j) <= r and (max(j) - min(j) >= x):
		return 1
	return 0
from itertools import combinations
(n, l, r, x) = list(map(int, input().split()))
c = list(map(int, input().rstrip().split()))
count = 0
for i in range(2, n + 1):
	a = list(combinations(c, i))
	for j in a:
		if check(j):
			count += 1
print(count)


from itertools import combinations
[n, l, r, x] = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
c.sort()
k = 0
from itertools import combinations
for i in range(n):
	for j in range(i + 1, n):
		if c[j] - c[i] >= x:
			if sum(c[i:j + 1]) < l:
				continue
			elif c[i] + c[j] > r:
				continue
			else:
				if c[i] + c[j] >= l and c[i] + c[j] <= r:
					k += 1
				for p in range(1, j - i):
					for m in combinations(c[i + 1:j], p):
						if sum(m) + c[i] + c[j] >= l and sum(m) + c[i] + c[j] <= r:
							k += 1
print(k)


import itertools
(n, l, r, x) = map(int, input().split())
li = list(map(int, input().split()))
cnt = 0
for i in range(2, n + 1):
	li1 = list(itertools.combinations(li, i))
	for k in li1:
		s = sum(k)
		if s >= l and s <= r and (max(k) - min(k) >= x):
			cnt += 1
print(cnt)


import itertools
(n, l, r, x) = map(int, input().split())
C = list(map(int, input().split()))
ans = 0
combi = []
for i in range(1, n + 1):
	tmp = [list(x) for x in itertools.combinations(C, i)]
	combi.extend(tmp)
for tmp in combi:
	s = sum(tmp)
	if s >= l and s <= r and (max(tmp) - min(tmp) >= x):
		ans += 1
print(ans)


(n, l, r, x) = [int(y) for y in input().split()]
c = [int(y) for y in input().split()]
c.sort()
ans = [0]

def solve(ans, tasklist=[], e=0):
	if sum(tasklist) <= r and sum(tasklist) >= l and (len(tasklist) >= 2) and (max(tasklist) - min(tasklist) >= x):
		ans[0] += 1
	for i in range(e, n):
		tasklist.append(c[i])
		solve(ans, tasklist, i + 1)
		del tasklist[len(tasklist) - 1]
solve(ans)
print(ans[0])


import sys
import math
import collections
import bisect

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def printSubsequences(arr, index, subarr, ans):
	if index == len(arr):
		if len(subarr) != 0:
			ans.append(subarr)
	else:
		printSubsequences(arr, index + 1, subarr, ans)
		printSubsequences(arr, index + 1, subarr + [arr[index]], ans)
	return ans
for t in range(1):
	(n, l, r, x) = get_ints()
	arr = get_list()
	ans = printSubsequences(arr, 0, [], [])
	count = 0
	for i in ans:
		if sum(i) >= l and sum(i) <= r and (max(i) - min(i) >= x):
			count += 1
	print(count)


a = []

def fn(x, n, l, r, k):
	sum = 0
	v = []
	for j in range(20):
		if 1 << j & x:
			v.append(a[j])
			sum += a[j]
	if len(v) < 2:
		return 0
	elif v[len(v) - 1] - v[0] >= k and sum >= l and (sum <= r):
		return 1
	else:
		return 0
(n, l, r, k) = input().split()
b = input().split()
for i in b:
	a.append(int(i))
a.sort()
ans = 0
for i in range(1 << int(n)):
	ans = ans + fn(i, int(n), int(l), int(r), int(k))
print(ans)


import sys
(n, l, r, x) = map(int, sys.stdin.readline().split())
c = list(map(int, sys.stdin.readline().split()))
ans = 0
for i in range(1 << n):
	td = 0
	min = 1000001
	max = 0
	for j in range(n):
		if i & 1 << j > 0:
			td += c[j]
			if c[j] > max:
				max = c[j]
			if c[j] < min:
				min = c[j]
	if td >= l and td <= r and (max - min >= x):
		ans += 1
print(ans)


(n, l, r, x) = (0, 0, 0, 0)
c = []

def judge(n, cjx):
	(inf, sup) = (float('inf'), -float('inf'))
	total = 0
	for i in range(n):
		if cjx[i]:
			total += c[i]
			inf = min(inf, c[i])
			sup = max(sup, c[i])
	return sup - inf >= x and l <= total and (total <= r)

def dfs(s, n, cjx):
	if s >= n:
		if judge(n, cjx):
			return 1
		else:
			return 0
	ans = 0
	cjx[s] = True
	ans += dfs(s + 1, n, cjx)
	cjx[s] = False
	ans += dfs(s + 1, n, cjx)
	return ans
(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
cjx = [False for i in range(n)]
print(dfs(0, n, cjx))


import itertools
(n, l, x1, r) = map(int, input().split())
li = [int(i) for i in input().split()]
a = []
for i in range(1, n + 1):
	x = itertools.combinations(li, i)
	a += x
count = 0
for j in a:
	if sum(list(j)) <= x1 and sum(list(j)) >= l:
		if max(j) - min(j) >= r:
			count += 1
print(count)


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	(n, l, r, x) = map(int, input().split())
	c = ain()
	count = 0
	for i in range(pow(2, n)):
		s = 0
		M = 0
		N = 0
		m = 1000000
		for j in range(n):
			if i & pow(2, j):
				N += 1
				s += c[j]
				m = min(m, c[j])
				M = max(M, c[j])
		if M - m >= x and l <= s and (r >= s) and (N > 1):
			count += 1
	print(count)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, left, right, diff) = map(int, input().split())
a = list(map(int, input().split()))
ret = 0
for mask in range(1 << n):
	if bin(mask).count('1') < 2:
		continue
	take = [a[i] for i in range(n) if mask >> i & 1]
	s = sum(take)
	d = max(take) - min(take)
	ret += left <= s <= right and d >= diff
print(ret)


from itertools import combinations

def subsetSums(arr):
	c = []
	for i in range(1, len(arr) + 1):
		c += list(combinations(arr, i))
	return c
(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ways = 0
a = subsetSums(a)
for i in range(len(a)):
	a[i] = list(a[i])
for i in range(len(a)):
	if l <= sum(a[i]) <= r and a[i][-1] - a[i][0] >= x:
		ways += 1
print(ways)


import math
from decimal import *
import random
from datetime import datetime
import time

def dfs(arr, mrk, cnt, l, r, x, ans, no, mn, mx, s, st):
	for i in range(s, len(arr)):
		if mrk[i] != 0:
			tmp = list(mrk)
			tmp[i] = 0
			if tuple(tmp) not in st:
				st.add(tuple(tmp))
				tcnt = int(cnt)
				tcnt += arr[i]
				val = int(arr[i])
				(tmx, tmn) = (max(mx, val), min(mn, val))
				if no >= 2:
					if (tcnt >= l and tcnt <= r) and tmx - tmn >= x:
						ans += 1
				ans = max(ans, dfs(arr, tmp, tcnt, l, r, x, ans, no + 1, tmn, tmx, s + 1, st))
	return ans
(n, l, r, x) = map(int, input().split())
arr = sorted(list(map(int, input().split())))
ans = dfs(arr, [1] * n, 0, l, r, x, 0, 1, int(10000000.0), -int(10000000.0), 0, set())
print(ans)


import itertools
(n, l, kk, x) = input().split()
n = int(n)
l = int(l)
kk = int(kk)
x = int(x)
arr = list(map(int, input().split()))
cnt = 0

def printCombination(arr, n, r):
	data = [0] * r
	combinationUtil(arr, data, 0, n - 1, 0, r)

def combinationUtil(arr, data, start, end, index, r):
	if index == r:
		lll = []
		for j in range(r):
			lll.append(data[j])
		ans.append(lll)
		return
	i = start
	while i <= end and end - i + 1 >= r - index:
		data[index] = arr[i]
		combinationUtil(arr, data, i + 1, end, index + 1, r)
		i += 1
ans = []
for r in range(2, n + 1):
	printCombination(arr, n, r)
for i in ans:
	if sum(i) >= l:
		if sum(i) <= kk:
			if max(i) - min(i) >= x:
				cnt = cnt + 1
print(cnt)


def isValid(arr, l, r, x):
	return l <= sum(arr) <= r and max(arr) - min(arr) >= x
(n, l, r, x) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
valid = 0
for mask in range(1, 1 << n):
	temp = []
	for i in range(n):
		if mask & 1 << i:
			temp.append(arr[i])
	if isValid(temp, l, r, x):
		valid += 1
print(valid)


(n, l, r, x) = map(int, input().split())
p = [int(x) for x in input().split()]
p = sorted(p)
s = 0
from itertools import combinations
result_list = sum([list(map(list, combinations(p, i))) for i in range(len(p) + 1)], [])
for i in result_list:
	if l <= sum(i) <= r and max(i) - min(i) >= x:
		s += 1
print(s)


import sys
(n, l, r, x) = map(int, input().split())
temp = []
temp = list(map(int, input().split()))
temp.sort()
ans = 0
for i in range(1 << n):
	score = 0
	_min = sys.maxsize
	_max = -sys.maxsize
	for j in range(n):
		if i & 1 << j > 0:
			_min = min(_min, temp[j])
			_max = max(_max, temp[j])
			score += temp[j]
	if score >= l and score <= r and (_max - _min >= x):
		ans += 1
print(ans)


(n, l, r, x) = map(int, input().split())
A = list(map(int, input().split()))
count = 0
for i in range(1 << n):
	total = 0
	mn = 1000000.0
	mx = -1000000.0
	for k in range(n):
		if i & 1 << k:
			total += A[k]
			mn = min(A[k], mn)
			mx = max(A[k], mx)
	if total <= r and total >= l and (mx - mn >= x):
		count += 1
print(count)


def main():
	import sys
	(n, l, r, x, *c) = [int(i) for i in sys.stdin.read().split()]
	result = 0
	for mask in range(1 << n):
		number = 0
		minimal = float('inf')
		maximal = -float('inf')
		s = 0
		for i in range(n):
			if mask & 1 << i:
				s += c[i]
				number += 1
				minimal = min(minimal, c[i])
				maximal = max(maximal, c[i])
		if number >= 2 and l <= s <= r and (maximal - minimal >= x):
			result += 1
	print(result)
main()


import itertools as it
(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
poss = []
for i in range(2, len(arr) + 1):
	p = list(it.combinations(arr, i))
	for j in p:
		poss.append(j)
ans = 0
for a in poss:
	a = sorted(a)
	if l <= sum(a) <= r and a[-1] - a[0] >= x:
		ans += 1
print(ans)


(n, l, r, x) = map(int, input().split())
l1 = list(map(int, input().split()))
ans = 0
from itertools import combinations
for i in range(2, n + 1):
	a = [0] * i
	for a in combinations(l1, i):
		if l <= sum(a) <= r:
			if max(a) - min(a) >= x:
				ans += 1
print(ans)


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
ans = 0
for mask in range(1 << n):
	a = []
	for bit in range(n):
		if mask & 1 << bit:
			a.append(c[bit])
	if len(a) >= 2 and max(a) - min(a) >= x and (l <= sum(a)) and (sum(a) <= r):
		ans += 1
print(ans)


def Solve(n, l, r, x, c):
	Num_ways = 0
	for k in range(2 ** n):
		Sum = 0
		k = list(bin(k).replace('0b', ''))
		while len(k) < n:
			k.insert(0, '0')
		Prob = []
		for i in range(n):
			if k[i] == '1':
				Prob.append(c[i])
		if len(Prob) > 0:
			(S, m, M) = (sum(Prob), min(Prob), max(Prob))
		else:
			(S, m, M) = (-1, -1, -1)
		if S >= l and S <= r and (M - m >= x):
			Num_ways += 1
	return Num_ways
(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
print(Solve(n, l, r, x, c))


from itertools import combinations
(n, l, r, x) = input().split()
n = int(n)
l = int(l)
r = int(r)
x = int(x)
a = list(map(int, input().strip().split()))[:n]
sublist = []
for i in range(2, len(a) + 1):
	for j in list(combinations(a, i)):
		sublist.append(j)
ans = 0
for i in sublist:
	if len(i) == 1:
		continue
	sum_ = 0
	for j in i:
		sum_ += j
	if max(i) - min(i) >= x:
		if sum_ >= l:
			if sum_ <= r:
				ans += 1
print(ans)


def rec(a, b, cur_sum):
	res = 0
	if cur_sum > r:
		return 0
	if cur_sum >= l:
		res += 1
	for el in C[a + 1:b]:
		if r >= cur_sum + el >= l:
			res += 1
	for i in range(a + 1, b):
		for j in range(i + 1, b):
			res += rec(i, j, cur_sum + C[i] + C[j])
	return res
(n, l, r, x) = map(int, input().split(' '))
C = list(map(int, input().split(' ')))
C.sort()
amount = 0
for i in range(n):
	for j in range(i + 1, n):
		if C[j] - C[i] >= x:
			amount += rec(i, j, C[i] + C[j])
print(amount)


(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
res = 0
for j in range(1, 2 ** n):
	a = [arr[i] for i in range(n) if j >> i & 1 == 1]
	s = sum(a)
	res += max(a) - min(a) >= x and s >= l and (s <= r)
print(res)


(n, l, r, x) = map(int, input().split())
c = [int(i) for i in input().split()]
ans = 0
for i in range(2 ** n):
	s = bin(i)[2:]
	s = '0' * (n - len(s)) + s
	cnt = 0
	for j in s:
		if j == '1':
			cnt += 1
	if cnt < 2:
		continue
	diff = 0
	ma = -1
	mi = 10 ** 10
	for j in range(len(s)):
		if s[j] == '1':
			diff += c[j]
			if c[j] > ma:
				ma = c[j]
			if c[j] < mi:
				mi = c[j]
	if l <= diff <= r and ma - mi >= x:
		ans += 1
print(ans)


def find(n, l, r, x, contests, lista):
	if n == 0:
		s = sum(lista)
		if s >= l and s <= r and (max(lista) - min(lista) >= x):
			return 1
		else:
			return 0
	c = 0
	for i in range(len(contests)):
		c += find(n - 1, l, r, x, contests[i + 1:], lista + [contests[i]])
	return c
(n, l, r, x) = list(map(int, input().split()))
contests = list(map(int, input().split()))
c = 0
for i in range(2, n + 1):
	c += find(i, l, r, x, contests, [])
print(c)


(n, l, r, x) = list(map(int, input().split()))
c = list(map(int, input().split()))
k = 0
for i in range(3, 1 << n):
	a = []
	for j in range(n):
		if i >> j & 1 == 1:
			a.append(c[j])
	a.sort()
	if len(a) >= 2:
		if sum(a) >= l and sum(a) <= r and (a[-1] - a[0] >= x):
			k += 1
print(k)


from itertools import *
(n, least, highest, x) = map(int, input().split())
l = [*map(int, input().split())]
cnt = 0
for i in range(2, n + 1):
	combination = [*map(list, combinations(l, i))]
	for j in range(len(combination)):
		combination[j].sort()
		total = sum(combination[j])
		if total >= least and total <= highest and (combination[j][-1] - combination[j][0] >= x):
			cnt += 1
print(cnt)


from itertools import combinations
(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
for i in range(2, n + 1):
	brr = list(combinations(arr, i))
	for j in brr:
		s = sum(j)
		if l <= s <= r and max(j) - min(j) >= x:
			ans += 1
print(ans)


import itertools

def judge(_list: int, _min: int, _max: int, _dif: int) -> int:
	count = 0
	for i in range(len(_list)):
		a = itertools.combinations(_list, i + 1)
		for j in a:
			if _min <= sum(j) <= _max and max(j) - min(j) >= _dif:
				count += 1
	return count
(number, mini, maxi, least_dif) = map(int, input().split())
dif_list = list(map(int, input().split()))
dif_list.sort()
print(judge(dif_list, mini, maxi, least_dif))


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
p = 1 << n
cnt = 0
for j in range(p):
	list1 = []
	if j > 0 and j & j - 1 != 0:
		for k in range(n):
			if j & 1 << k:
				list1.append(c[k])
		if sum(list1) >= l and sum(list1) <= r and (list1[-1] - list1[0] >= x):
			cnt += 1
print(cnt)


(n, l, r, x) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
k = 1 << n
res = 0
lst = 0
for i in range(k):
	num = 0
	cnt = 0
	fst = -1
	for j in range(n):
		if 1 << j & i != 0:
			num += a[j]
			cnt += 1
			if fst == -1:
				fst = j
			lst = j
	if cnt > 1 and a[lst] - a[fst] >= x and (num >= l) and (num <= r):
		res += 1
print(res)


(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
import itertools
count = 0
lst = []
for i in range(2, n + 1):
	lst.append(list(itertools.combinations(arr, i)))
for i in lst:
	for j in i:
		if sum(list(j)) >= l and sum(list(j)) <= r and (max(list(j)) - min(list(j)) >= x):
			count += 1
print(count)


import itertools
(n, l, r, x) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
counter = 0
for (i, val) in enumerate([''.join(seq) for seq in itertools.product('01', repeat=n)]):
	if val.count('1') < 2:
		continue
	dif = 0
	mx = float('-inf')
	mn = float('inf')
	for (i, bit) in enumerate(val):
		if bit == '1':
			dif += c[i]
			mx = max(c[i], mx)
			mn = min(c[i], mn)
	if l <= dif <= r and mx - mn >= x:
		counter += 1
print(counter)


values = input()
values = values.split()
n = int(values[0])
l = int(values[1])
r = int(values[2])
x = int(values[3])
ci = input()
ci = ci.split()
for i in range(len(ci)):
	ci[i] = int(ci[i])
count = 0

def sub_lists(l):
	base = []
	lists = [base]
	for i in range(len(l)):
		orig = lists[:]
		new = l[i]
		for j in range(len(lists)):
			lists[j] = lists[j] + [new]
		lists = orig + lists
	return lists
lists = sub_lists(ci)
for i in lists:
	if len(i) > 1:
		if sum(i) >= l and sum(i) <= r and (max(i) - min(i) >= x):
			count += 1
print(count)


(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))
answer = 0
for i in range(2 ** n):
	arr1 = []
	for j in range(n):
		if i // 2 ** j % 2 == 1:
			arr1.append(arr[j])
	if len(arr1) >= 2 and l <= sum(arr1) <= r and (max(arr1) - min(arr1) >= x):
		answer += 1
print(answer)


def gen(k, n, p):
	if k == n:
		ans.append(p)
		return
	gen(k + 1, n, p + [1])
	gen(k + 1, n, p + [0])
(n, l, r, x) = map(int, input().split())
m = list(map(int, input().split()))
ans = []
count = 0
gen(0, n, [])
for i in range(len(ans)):
	now = []
	for j in range(len(ans[i])):
		if ans[i][j] == 1:
			now.append(m[j])
	now.sort()
	sum = 0
	for i in now:
		sum += i
	if len(now) > 0:
		if now[-1] - now[0] >= x and sum >= l and (sum <= r):
			count += 1
print(count)


from itertools import combinations
(n, l, r, x) = (int(_) for _ in input().split())
c = [int(_) for _ in input().split()]
ans = 0
for k in range(2, n + 1):
	for comb in combinations(c, k):
		if l <= sum(comb) <= r and max(comb) - min(comb) >= x:
			ans += 1
print(ans)


def check_bits(x, n):
	total = 0
	for i in range(n):
		if x & 1 << i:
			total += 1
	return total >= 2

def check_compex(x, data, l, r, diff):
	total_c = 0
	min_c = None
	max_c = None
	for i in range(len(data)):
		if x & 1 << i:
			total_c += data[i]
			if min_c is None or min_c > data[i]:
				min_c = data[i]
			if max_c is None or max_c < data[i]:
				max_c = data[i]
	return l <= total_c <= r and max_c - min_c >= diff

def __starting_point():
	(n, l, r, diff) = list(map(int, input().split()))
	data = list(map(int, input().split()))
	total = 0
	for i in range(2 ** n):
		if check_bits(i, n) and check_compex(i, data, l, r, diff):
			total += 1
	print(total)
__starting_point()


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
	mask = bin(i)[2:].zfill(n)
	temp = [c[j] for j in range(n) if int(mask[j])]
	ans += l <= sum(temp) <= r and max(temp) - min(temp) >= x
print(ans)


[n, l, r, x] = list(map(int, input().strip().split()))
Cs = list(sorted(map(int, input().strip().split())))
probs = 0
for i in range(1, 2 ** n):
	currsub = [Cs[j] for j in range(n) if i & 1 << j]
	probs += len(currsub) > 1 and l <= sum(currsub) <= r and (currsub[-1] - currsub[0] >= x)
print(probs)


def generate(made, lis):
	if made == n:
		nonlocal res
		s = sum(lis)
		if l <= s and s <= r and (len(lis) >= 2) and (lis[-1] - lis[0] >= x):
			res += 1
	else:
		generate(made + 1, lis + [a[made]])
		generate(made + 1, lis)
(n, l, r, x) = list(map(int, input().split()))
a = sorted(map(int, input().split()))
res = 0
generate(0, [])
print(res)


import itertools
(n, l, r, var) = (int(x) for x in input().split())
arr = list((int(x) for x in input().split()))
ans = 0
for i in range(2, len(arr) + 1):
	for comb in itertools.combinations(arr, i):
		curComb = list(comb)
		if sum(curComb) <= r and sum(curComb) >= l and (max(curComb) - min(curComb) >= var):
			ans += 1
print(ans)


def check_combos(diff, n, size, start, picked, total, l, r, x, combination=[]):
	if picked == size:
		if max(combination) - min(combination) >= x and l <= sum(combination) <= r:
			total += 1
	else:
		for i in range(start, n - (size - picked - 1)):
			combination.append(diff[i])
			picked += 1
			total = check_combos(diff, n, size, i + 1, picked, total, l, r, x, combination)
			picked -= 1
			combination.pop()
	return total

def prog():
	(n, l, r, x) = map(int, input().split())
	diff = list(map(int, input().split()))
	suitable_problemsets = 0
	for size in range(1, n + 1):
		suitable_problemsets += check_combos(diff, n, size, 0, 0, 0, l, r, x)
	print(suitable_problemsets)
prog()


(n, l, r, x) = list(map(int, input().split()))
b = list(map(int, input().split()))
if len(b) == 1:
	print(0)
else:
	w = ['0', '1']
	e = 0
	t = len(b)
	while t - 1 > 0:
		k = []
		for i in w:
			k.append('0' + i)
		for i in w:
			k.append('1' + i)
		w = k
		t = t - 1
	for i in k:
		a = []
		for j in range(n):
			if i[j] == '1':
				a.append(b[j])
		s = sum(a)
		if len(a) > 1 and s >= l and (s <= r) and (max(a) - min(a) >= x):
			e = e + 1
	print(e)


(_n, l, r, x) = map(int, input('').split())
c = list(map(int, input().split()))
count = 0

def backtrack(s, l, r, x, c, i, level, min, max):
	if s > r:
		return 0
	if s >= l and max - min >= x:
		global count
		count += 1
	for j in range(i, len(c)):
		new = c[j]
		(nmax, nmin) = (max, min)
		if new > max:
			nmax = new
		if new < min:
			nmin = new
		backtrack(s + new, l, r, x, c, j + 1, level + 1, nmin, nmax)
backtrack(0, l, r, x, c, 0, 0, 9999999999, 0)
print(count)


(n, ll, r, x) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
subset = []
for i in range(1, 2 ** n):
	sub = []
	for j in range(n):
		if 1 << j & i > 0:
			sub.append(l[j])
	subset.append(sub)
c = 0
for i in subset:
	if len(i) > 1:
		su = sum(i)
		if (su >= ll and su <= r) and max(i) - min(i) >= x:
			c += 1
print(c)


def recursion(index, sub_problem):
	if index == len(list_value):
		return [sub_problem]
	else:
		all_sub_problem = []
		choosing_index = recursion(index + 1, sub_problem + [list_value[index]])
		not_choosing_index = recursion(index + 1, sub_problem)
		for element in choosing_index:
			if minimum_difficulties <= sum(element) <= maximum_difficulties and max(element) - min(element) >= minimum_difficulty_difference:
				all_sub_problem.append(element)
		for element in not_choosing_index:
			if minimum_difficulties <= sum(element) <= maximum_difficulties and max(element) - min(element) >= minimum_difficulty_difference:
				all_sub_problem.append(element)
		return all_sub_problem
(number_of_problems, minimum_difficulties, maximum_difficulties, minimum_difficulty_difference) = map(int, input().strip().split(' '))
list_value = list(map(int, input().strip().split(' ')))
result = recursion(0, [])
print(len(result))


from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from sys import *
from re import *

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
(n, l, r, x) = zzz()
arr = zzz()
cnt = 0
for i in range(2, 2 ** n):
	b = bin(i)[2:]
	b = '0' * (n - len(b)) + b
	(s, mx, mi) = (0, float('-inf'), float('inf'))
	for j in range(n):
		if b[j] == '1':
			mx = max(mx, arr[j])
			mi = min(mi, arr[j])
			s += arr[j]
	if s >= l and s <= r and (mx - mi >= x):
		cnt += 1
print(cnt)


I = lambda : map(int, input().split())
(n, l, r, x) = I()
t = sorted(I())
k = [0]

def f(n, q, w, e):
	if n < 0:
		k[0] += q and w - q >= x and (l <= e <= r)
		return
	f(n - 1, q, w, e)
	if w:
		q = t[n]
	else:
		w = t[n]
	f(n - 1, q, w, e + t[n])
f(n - 1, 0, 0, 0)
print(k[0])


from itertools import chain, combinations

def powerset(iterable):
	s = list(iterable)
	return chain.from_iterable((combinations(s, r) for r in range(1, len(s) + 1)))
(n, l, r, x) = map(int, input().split())
cantidad_de_formas = 0
difficulties = powerset(map(int, input().split()))
for combinacion in difficulties:
	if len(combinacion) > 1:
		if max(combinacion) - min(combinacion) >= x:
			suma = sum(combinacion)
			if suma >= l and suma <= r:
				cantidad_de_formas += 1
print(cantidad_de_formas)


def calc(str, n, mn, mx, dif):
	end = 2 ** n
	binary = ''
	index = -1
	mnx = 100000000
	mxx = -1
	sum = 0
	count = 0
	for i in range(end):
		binary = '{0:015b}'.format(i)[::-1]
		binary = binary[:n]
		index = -1
		sum = 0
		mnx = 100000000
		mxx = -1
		for k in binary:
			index += 1
			if k == '1':
				sum += str[index]
				mnx = min(mnx, str[index])
				mxx = max(mxx, str[index])
		if sum <= mx and sum >= mn and (mxx - mnx >= dif):
			count += 1
	return count
(n, mn, mx, dif) = map(int, input().split())
x = list(map(int, input().split()))
print(calc(x, n, mn, mx, dif))


import itertools
s1 = input()
s1 = s1.split()
s2 = input()
s2 = s2.split()
nlrx = [int(x) for x in s1]
nci = [int(x) for x in s2]
result = [seq for i in range(0, len(nci) + 1) for seq in itertools.combinations(nci, i) if sum(seq) >= nlrx[1] and sum(seq) <= nlrx[2] and (max(seq) - min(seq) >= nlrx[3])]
print(len(result))


from sys import stdin
(n, l, r, x) = map(int, input().split())
problems = list(map(int, input().split()))
count = 0
for check in range(1 << n):
	pset = []
	tmp = check
	for i in range(n):
		if tmp & 1 == 1:
			pset.append(problems[i])
		tmp >>= 1
	if len(pset) > 1 and sum(pset) >= l and (sum(pset) <= r) and (max(pset) - min(pset) >= x):
		count += 1
print(count)


def generate(i, real, a):
	if i == n:
		if real >= 2:
			min_a = a[0]
			max_a = a[real - 1]
			sum_a = sum(a)
			if sum_a >= l and sum_a <= r and (max_a - min_a >= x):
				count[0] += 1
	else:
		generate(i + 1, real + 1, a + [c[i]])
		generate(i + 1, real, a)
(n, l, r, x) = map(int, input().split())
c = sorted(list(map(int, input().split())))
count = [0]
generate(0, 0, [])
print(count[0])


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
count = 0
for i in range(2 ** n):
	b = bin(i)[2:]
	b = '0' * (n - len(b)) + b
	(minn, maxx) = (10 ** 18, 0)
	s = 0
	for j in range(n):
		if b[j] == '1':
			minn = min(minn, c[j])
			maxx = max(maxx, c[j])
			s += c[j]
	if s >= l and s <= r and (maxx - minn >= x):
		count += 1
print(count)


def getSub(l, i):
	j = -1
	r = []
	while i > 0:
		if i % 2 == 1:
			r.append(l[j])
		i //= 2
		j -= 1
	return r
(n, l, r, x) = map(int, input().split())
cs = list(map(int, input().split()))
count = 0
cs.sort()
for subI in range(1, 2 ** n):
	sub = getSub(cs, subI)
	if len(sub) < 2:
		continue
	dist = sub[0] - sub[-1]
	if dist < x:
		continue
	s = sum(sub)
	if s < l or s > r:
		continue
	count += 1
print(count)


(n, l, r, x) = map(int, input().split())
d = list(map(int, input().split()))
ans = 0
for i in range(pow(2, n) - 1, -1, -1):
	s = bin(i)[2:]
	while len(s) < n:
		s = '0' + s
	diff = 0
	t = []
	for j in range(n):
		if s[j] == '1':
			diff += d[j]
			t.append(d[j])
	t.sort()
	if l <= diff <= r and t[-1] - t[0] >= x:
		ans += 1
print(ans)


vals = input().split()
n = int(vals[0])
l = int(vals[1])
r = int(vals[2])
x = int(vals[3])
plist = input().split()
pbs = []
for i in range(n):
	pbs.append(int(plist[i]))
if n == 1:
	print(0)
elif n == 2:
	if pbs[0] + pbs[1] >= l and pbs[0] + pbs[1] <= r and (abs(pbs[0] - pbs[1]) >= x):
		print(1)
	else:
		print(0)
else:
	answer = 0
	allmasks = 1 << n
	for i in range(allmasks):
		pbnum = 0
		pbsum = 0
		pbmin = 1000001
		pbmax = 0
		for j in range(n):
			if i & 1 << j > 0:
				pval = pbs[j]
				pbnum += 1
				pbsum += pval
				if pval > pbmax:
					pbmax = pval
				if pval < pbmin:
					pbmin = pval
		if pbnum >= 2 and pbsum >= l and (pbsum <= r) and (pbmax - pbmin >= x):
			answer += 1
	print(answer)


from itertools import combinations
(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
arr = []
for i in range(2, n + 1):
	ar = combinations(a, i)
	for j in ar:
		arr += [list(j)]
count = 0
for i in arr:
	dif = max(i) - min(i)
	total = sum(i)
	if dif >= x and (total >= l and total <= r):
		count += 1
print(count)


from itertools import chain, combinations

def powerset(x):
	s = list(x)
	return chain.from_iterable((combinations(s, r) for r in range(len(s) + 1)))
(n, l, r, x) = [int(s) for s in input().split(' ')]
c = [int(s) for s in input().split(' ')]
cnt = 0
for a in powerset(c):
	if a and max(a) - min(a) >= x and (l <= sum(a) <= r):
		cnt += 1
print(cnt)


import itertools

def classify(subset, l, r, x):
	li = []
	for i in subset:
		li.append(i)
	f1 = False
	f2 = False
	f3 = False
	s = 0
	for i in li:
		s += i
	if s >= l:
		f1 = True
	if s <= r:
		f2 = True
	li.sort()
	t = li[len(li) - 1] - li[0]
	if t >= x:
		f3 = True
	if f1 and f2 and f3:
		return True
	else:
		return False
s = input()
s = s.split()
n = int(s[0])
l = int(s[1])
r = int(s[2])
x = int(s[3])
a = input()
a = a.split()
arr = []
for i in a:
	arr.append(int(i))
count = 0
for i in range(2, len(arr) + 1):
	for subset in itertools.combinations(arr, i):
		if classify(subset, l, r, x):
			count += 1
print(count)


(n, l, r, x) = map(int, input().split())
arr = list(map(int, input().split()))

def solve():
	count = 0
	for i in range(1 << n):
		minv = float('inf')
		maxv = 0
		total = 0
		for j in range(n):
			if i & 1 << j:
				total += arr[j]
				minv = min(minv, arr[j])
				maxv = max(maxv, arr[j])
		if l <= total and total <= r and (maxv - minv >= x):
			count += 1
	return count
print(solve())


def s():
	[n, l, r, x] = list(map(int, input().split(' ')))
	l -= 1
	r += 1
	a = list(map(int, input().split(' ')))
	s = 0
	for i in range(1, 1 << n):
		ind = 0
		k = []
		while i:
			if i & 1:
				k.append(a[ind])
			ind += 1
			i >>= 1
		if max(k) - min(k) >= x and l < sum(k) < r:
			s += 1
	print(s)
s()


from itertools import combinations
(n, l, r, x) = map(int, input().split())
c = [*map(int, input().split())]
print(sum([sum([1 if max(j) - min(j) >= x and l <= sum(j) <= r else 0 for j in combinations(c, i)]) for i in range(1, n + 1)]))


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
all_sub = []
for i in range(2 ** n):
	subset = []
	for j in range(n):
		if i & 1 << j != 0:
			subset.append(c[j])
	all_sub.append(subset)
final = 0
for i in all_sub[1:]:
	if i[-1] - i[0] >= x and sum(i) >= l and (sum(i) <= r):
		final += 1
print(final)


(n, l, r, x) = tuple(map(int, input('').split(' ')))
nums = list(map(int, input('').split(' ')))
output = 0
for bit in range(2 ** n):
	temp = []
	for i in range(n):
		score = nums[i]
		if bit & 2 ** i:
			temp.append(score)
	if sum(temp) >= l and sum(temp) <= r and (max(temp) - min(temp) >= x):
		output += 1
print(output)


from itertools import combinations
from sys import stdin
input = stdin.readline
intin = lambda : map(int, input().split())
(n, l, r, x) = intin()
(*a,) = intin()
print(sum([sum([max(j) - min(j) >= x and l <= sum(j) <= r for j in combinations(a, i)]) for i in range(2, n + 1)]))


from itertools import chain, combinations

def powerset(iterable):
	xs = list(iterable)
	return list(chain.from_iterable((combinations(xs, n) for n in range(2, len(xs) + 1))))
(n, l, r, x) = map(int, input().split())
sett = list(map(int, input().split()))
psett = powerset(sett)
count = 0
for i in psett:
	k = sorted(i)
	j = sum(k)
	if j >= l and j <= r and (k[-1] - k[0] >= x):
		count += 1
print(count)


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
(n, l, r, x) = IL()
cArr = sorted(IL())
ans = 0
for i in range(1, 2 ** n):
	csub = [cArr[j] for j in range(n) if i & 2 ** j]
	if l <= sum(csub) <= r and csub[-1] - csub[0] >= x:
		ans += 1
print(ans)


(n, l, r, x) = map(int, input().split())
import math
z = list(map(int, input().split()))
count = 0
for i in range(pow(2, len(z))):
	mini = math.inf
	maxa = 0
	j = i
	inde = 0
	sume = 0
	while j > 0:
		if j & 1:
			sume += z[inde]
			maxa = max(maxa, z[inde])
			mini = min(mini, z[inde])
		j = j >> 1
		inde += 1
	if maxa - mini >= x and l <= sume <= r:
		count += 1
print(count)


(n, l, r, x) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, 2 ** n + 1):
	j = bin(i)
	j = j[2:]
	if len(j) < n:
		j = '0' * (n - len(j)) + j
	c = 0
	temp = []
	for k in j:
		if k == '1':
			temp.append(a[c])
		c += 1
	s = sum(temp)
	if len(temp) >= 2 and s >= l and (s <= r) and (max(temp) - min(temp) >= x):
		ans += 1
print(ans)


def I():
	return list(map(int, input().split()))
(n, l, r, x) = I()
c = I()
l1 = list(range(2 ** n))
ans = 0
for j in l1:
	s = 0
	num = 0
	ma = 0
	mi = 100000000
	for i in range(n):
		if j & 1 << i:
			num += 1
			s += c[i]
			ma = max(c[i], ma)
			mi = min(c[i], mi)
	if s <= r and l <= s and (ma - mi >= x) and (num >= 2):
		ans += 1
print(ans)


(n, l, r, x) = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
seq.sort()
count = 0

def get_bit(i, n):
	ele = bin(i)[2:]
	ele = [int(x) for x in ele]
	ele = (n - ele.__len__()) * [0] + ele
	return ele
for i in range(1, 2 ** n):
	situ = get_bit(i, n)
	summing = 0
	maxj = 0
	minj = 100
	for j in range(n):
		summing += situ[j] * seq[j]
		if situ[j] == 1:
			maxj = max(maxj, j)
			minj = min(j, minj)
	gap = seq[maxj] - seq[minj]
	if summing <= r and summing >= l and (gap >= x):
		count += 1
print(count)


def f(k, n, ma, mi, sum):
	if k:
		if sum + k[0] <= r and sum + k[0] >= l and (max(k[0], ma) - min(k[0], mi) >= x):
			n += 1
		if sum <= r:
			n = f(k[1:], n, ma, mi, sum)
			n = f(k[1:], n, max(k[0], ma), min(k[0], mi), sum + k[0])
	return n
(n, l, r, x) = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
n = f(s, 0, 0, 10 ** 9, 0)
print(n)


kk = lambda : map(int, input().split())
ll = lambda : list(kk())
(n, l, r, d) = kk()
(p, t) = (ll(), 0)
for v in range(2 ** n):
	s = []
	for i in range(n):
		if v & 2 ** i:
			s.append(p[i])
	if l <= sum(s) <= r and max(s) - min(s) >= d:
		t += 1
print(t)


(n, l, r, x) = map(int, input().split())
tasks = list(map(int, input().split()))
mask = 3
ans = 0
while mask < 1 << n:
	sum_dif = 0
	min_diff = float('inf')
	max_diff = -float('inf')
	if mask & mask - 1:
		for i in range(n):
			if mask & 1 << i:
				sum_dif += tasks[i]
				min_diff = min(min_diff, tasks[i])
				max_diff = max(max_diff, tasks[i])
		if x <= max_diff - min_diff and l <= sum_dif <= r:
			ans += 1
	mask += 1
print(ans)


(n, l, r, x) = map(int, input().split())
c = input().split()
for i in range(n):
	c[i] = int(c[i])
ans = 0
for i in range(1, 2 ** n):
	s = bin(i)
	s = s[2:]
	s = '0' * (n - len(s)) + s
	if s.count('1') >= 2:
		total = 0
		maxi = 0
		mini = 10 ** 6 + 1
		for j in range(n):
			if s[j] == '1':
				total += c[j]
				maxi = max(maxi, c[j])
				mini = min(mini, c[j])
		if l <= total <= r and maxi - mini >= x:
			ans += 1
print(ans)


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))

def check(a):
	s = sum(a)
	global l, r, x
	return max(a) - min(a) >= x and s >= l and (s <= r)
res = 0
for t in range(1, 2 ** n):
	a = [c[i] for i in range(n) if t >> i & 1 == 1]
	if check(a):
		res += 1
print(res)


import itertools
(n, l, r, x) = input().split(' ')
n = int(n)
l = int(l)
r = int(r)
x = int(x)
num = [int(i) for i in input().split()]
count = 0
for i in range(2, n + 1):
	for j in itertools.combinations(num, i):
		if max(j) - min(j) >= x and l <= sum(j) <= r:
			count += 1
print(count)


import itertools
(n, l, r, x) = input().split()
n = int(n)
l = int(l)
r = int(r)
x = int(x)
numbers = [int(z) for z in input().split()]
numbers = sorted(numbers)
count = 0
for z in range(2, len(numbers) + 1):
	for subset in itertools.combinations(numbers, z):
		total = sum(subset)
		if total >= l and total <= r and (subset[-1] - subset[0] >= x):
			count += 1
print(count)


(n, l, r, hard) = list(map(int, input().split()))
val = list(map(int, input().split()))
arr = []
for i in range(0, 2 ** n):
	x = bin(i)
	x = x.split('b')[1]
	x = '0' * (n - len(x)) + x
	arr.append(x)
ans = 0
for i in arr:
	if i.count('1') >= 2:
		cur = i
		temp = []
		for j in range(n):
			if cur[j] == '1':
				temp.append(val[j])
		(p, q) = (max(temp), min(temp))
		t = sum(temp)
		if p - q >= hard and (t >= l and t <= r):
			ans += 1
print(ans)


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : list(input())
(n, l, r, x) = ml()
a = ll()
ans = 0
lol = pow(2, n)
for i in range(lol):
	mx = 0
	mn = 10 ** 18
	s = 0
	cnt = 0
	for j in range(n):
		if i & 1 << j:
			s += a[j]
			mx = max(mx, a[j])
			mn = min(mn, a[j])
			cnt += 1
	if cnt > 1 and s >= l and (s <= r) and (mx - mn >= x):
		ans += 1
print(ans)


(n, l, r, x) = (int(x) for x in input().split())
c = [int(x) for x in input().split()]
c.sort()
ans = 0
for i in range(1, 2 ** n):
	cur = []
	for j in range(n):
		if i & 1 << j:
			cur.append(c[j])
	if cur[-1] - cur[0] < x:
		continue
	if l <= sum(cur) <= r:
		ans += 1
print(ans)


(n, l, r, x) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
res = 0
for i in range(2, 1 << len(a)):
	cmin = 10 ** 9 + 1
	cmax = 0
	ctotal = 0
	for j in range(len(a)):
		if i & 1 << j:
			cmin = min(a[j], cmin)
			cmax = max(a[j], cmax)
			ctotal += a[j]
	if ctotal >= l and ctotal <= r and (cmax - cmin >= x):
		res += 1
print(res)


import itertools
(n, l, r, x) = map(int, input().split())
problems = [int(num) for num in input().split()]
kinds = 0
for i in range(2, n + 1):
	sublists = list(itertools.combinations(problems, i))
	for sublist in sublists:
		sublist = list(sublist)
		if l <= sum(sublist) <= r and max(sublist) - min(sublist) >= x:
			kinds += 1
print(kinds)


(n, l, w, x) = map(int, input().split())
arr = list(map(int, input().split()))
n = len(arr)
ans = 0
for r in range(2, n + 1):
	show = list(range(r))
	data = [0] * r
	while max(show) <= n - 1:
		for i in range(r):
			data[i] = arr[show[i]]
		if l <= sum(data) <= w and max(data) - min(data) >= x:
			ans += 1
		for q in range(1, r):
			if show[q] == n - r + q:
				show[q - 1] += 1
				for j in range(q, r):
					show[j] = 1 + show[j - 1]
				break
			if q == r - 1:
				show[-1] += 1
print(ans)


from itertools import combinations
(num, min_dif, max_dif, easy_hard_dif) = map(int, input().split(' '))
arr = [int(m) for m in input().split(' ')]
all_combinations = []
for x in range(2, num + 1):
	combs = combinations(arr, x)
	for abc in combs:
		all_combinations.append(list(abc))
possible_answers = 0
for a in all_combinations:
	if sum(a) >= min_dif and sum(a) <= max_dif and (max(a) - min(a) >= easy_hard_dif):
		possible_answers += 1
print(possible_answers)


import itertools
limits = [int(x) for x in input().split()]
problems = [int(x) for x in input().split()]
n = limits[0]
l = limits[1]
r = limits[2]
x = limits[3]
kinds = 0
problems.sort()
for i in range(2, n + 1):
	sublists = list(itertools.combinations(problems, i))
	for sublist in sublists:
		sublist = list(sublist)
		if sum(sublist) < l or sum(sublist) > r:
			continue
		if sublist[len(sublist) - 1] - sublist[0] >= x:
			kinds += 1
print(kinds)


import sys

def answer(n, l, r, x, c):
	num_ways = 0
	ctr = 1
	while ctr < 2 ** n:
		s = bin(ctr)[2:].zfill(n)
		t_ary = []
		summ = 0
		mx = 0
		mn = 10 ** 7
		for i in range(n):
			if s[i] == '1':
				t_ary.append(c[i])
				summ += c[i]
				mx = max(mx, c[i])
				mn = min(mn, c[i])
		if len(t_ary) < 2:
			ctr += 1
			continue
		if summ < l:
			ctr += 1
			continue
		if summ > r:
			ctr += 1
			continue
		if mx - mn < x:
			ctr += 1
			continue
		num_ways += 1
		ctr += 1
	return num_ways

def main():
	(n, l, r, x) = map(int, sys.stdin.readline().split())
	c = tuple(map(int, sys.stdin.readline().split()))
	print(answer(n, l, r, x, c))
	return
main()


import itertools
(n, l, r, x) = map(int, input().split())
a = [int(y) for y in input().split()]
ans = 0
for i in range(2, n + 1):
	combs = itertools.combinations(a, i)
	for comb in combs:
		sum = 0
		for j in comb:
			sum += j
		dif = max(comb) - min(comb)
		if sum >= l and sum <= r and (dif >= x):
			ans += 1
print(ans)


def main():
	(n, l, r, x) = list(map(int, input().split()))
	C = list(map(int, input().split()))
	ans = 0
	for i in range(1 << n):
		use = []
		for j in range(n):
			if i >> j & 1:
				use.append(C[j])
		if use == []:
			continue
		if max(use) - min(use) >= x and l <= sum(use) <= r:
			ans += 1
	print(ans)
main()


(N, L, R, X) = map(int, input().split())
C = list(map(int, input().split()))
Ans = 0
for Cf in range(1, 1 << N):
	V = [C[i] for i in range(N) if Cf & 1 << i > 0]
	if max(V) - min(V) >= X and L <= sum(V) and (sum(V) <= R):
		Ans += 1
print(Ans)


result = 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.sort()
jojo = []
for i in range(2 ** len(b)):
	for j in range(len(b)):
		if bool(i & 1 << j) == bool(1):
			jojo.append(b[j])
	if len(jojo) > 0:
		if jojo[len(jojo) - 1] - jojo[0] >= a[3] and sum(jojo) <= a[2] and (sum(jojo) >= a[1]):
			result += 1
	jojo = []
print(result)


(n, l, r, x) = (0, 0, 0, 0)
(c, sumC) = ([], [])

def solve(step, totalC, num, maxC, minC):
	if step == n:
		if totalC >= l and totalC <= r and (num >= 2) and (maxC - minC >= x):
			return 1
		else:
			return 0
	if totalC > r:
		return 0
	if totalC + sumC[step] < l:
		return 0
	return solve(step + 1, totalC, num, maxC, minC) + solve(step + 1, totalC + c[step], num + 1, max(maxC, c[step]), min(minC, c[step]))
(n, l, r, x) = [int(x) for x in input().strip().split()]
c = [int(x) for x in input().strip().split()]
c.sort(reverse=True)
sumC = [sum(c[i:]) for i in range(0, n)]
sumC.append(0)
print(solve(0, 0, 0, 0, 10 ** 6 + 1))


(n, l, r, x) = map(int, input().split())
nums = sorted(list(map(int, input().split())))
ans = 0

def recurse(i, sum, dif, cnt):
	global ans
	if i == n:
		if not cnt:
			return
		if sum >= l and sum <= r and (abs(cnt[-1] - cnt[0]) >= x):
			ans += 1
		return
	recurse(i + 1, sum, dif, cnt[:])
	cnt.append(nums[i])
	recurse(i + 1, sum + nums[i], dif, cnt[:])
recurse(0, 0, 0, [])
print(ans)


(N, L, R, X) = map(int, input().split())
A = list(map(int, input().split()))
k = 0
for i in range(2 ** N):
	P = []
	for j in range(N):
		if i & 1 << j != 0:
			P.append(A[j])
	if len(P) > 1:
		if L <= sum(P) <= R and max(P) - min(P) >= X:
			k += 1
print(k)


(n, l, r, x) = map(int, input().split())
c = list(map(int, input().split()))
ans = 0
for mask in range(2 ** n):
	(cnt, csum) = (0, 0)
	(mn, mx) = (10 ** 18, -10 ** 18)
	for i in range(n):
		if mask & 1 << i != 0:
			cnt += 1
			csum += c[i]
			mn = min(mn, c[i])
			mx = max(mx, c[i])
	if cnt >= 2 and csum >= l and (csum <= r) and (mx - mn >= x):
		ans += 1
print(ans)


import itertools

def subsets(M):
	L = list(M)
	n = len(L)
	for i in range(1 << n):
		mask = [i >> k & 1 for k in range(n)]
		yield list(itertools.compress(L, mask))
	return
(n, l, r, x) = [int(x) for x in input().split()]

def check(subset):
	if len(subset) < 2:
		return False
	(a, b) = (min(subset), max(subset))
	return b - a >= x and l <= sum(subset) <= r
c = [int(x) for x in input().split()]
print(len(list(filter(check, subsets(c)))))