https://www.acmicpc.net/problem/16938
import java.io.*;
import java.util.*;
public class Main {
    static int N, L, R, X, ans;
    static int[] A;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        N = Integer.parseInt(st.nextToken());
        L = Integer.parseInt(st.nextToken());
        R = Integer.parseInt(st.nextToken());
        X = Integer.parseInt(st.nextToken());
        A = new int[N];
        st = new StringTokenizer(br.readLine());
        for(int i = 0; i < N; i++){
            A[i] = Integer.parseInt(st.nextToken());
        }
        dfs(0,0,0,Integer.MIN_VALUE,Integer.MAX_VALUE);
        System.out.print(ans);
    }
    static void dfs(int idx, int cnt, int sum, int max, int min){
        if(idx == N){
            if(cnt < 2 || L > sum || R < sum || X > max - min){
                return;
            }
            ans++;
            return;
        }
        int nMax = Math.max(max, A[idx]);
        int nMin = Math.min(min, A[idx]);
        dfs(idx + 1, cnt + 1, sum + A[idx], nMax, nMin);
        dfs(idx + 1, cnt, sum, max, min);
    }
}