using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_DPL_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NKTR = ReadLong();
            long N = NKTR[0];
            int K = (int)NKTR[1];
            long L = NKTR[2];
            long R = NKTR[3];

            long[] A = ReadLong();

            long[] A1 = A.Take((int)N / 2).ToArray();   //前半
            long[] A2 = A.Skip((int)N / 2).ToArray();   //後半

            //前半の合計と枚数
            List<long>[] sumA1 = new List<long>[A1.Length + 1].Select(x=>new List<long>()).ToArray();
            foreach (var c in BitSearch(A1.Length))
            {
                long sum = 0;
                foreach (var i in c)
                {
                    sum += A1[i];
                }
                sumA1[c.Length].Add(sum);
            }

            //後半の合計と枚数
            List<long>[] sumA2 = new List<long>[A2.Length + 1].Select(x=>new List<long>()).ToArray();
            foreach (var c in BitSearch(A2.Length))
            {
                long sum = 0;
                foreach (var i in c)
                {
                    sum += A2[i];
                }
                sumA2[c.Length].Add(sum);
            }

            //後半のソート
            long[][] sortedA2 = new long[A2.Length + 1][];
            for (int i = 0; i < A2.Length + 1; i++)
            {
                sortedA2[i] = sumA2[i].OrderBy(x => x).ToArray();
            }

            //列挙 O(K*NlogN)
            long ans = 0;
            for (int k = 0; k <= K; k++)
            {
                int k1 = k;
                int k2 = K - k;

                if (k1 >= sumA1.Length) continue;
                if (k2 >= sumA2.Length) continue;

                foreach (var c1 in sumA1[k1])
                {
                    long r1 = L - c1;
                    long r2 = R - c1;

                    ans += UpperBound(sortedA2[k2], r2) - LowerBound(sortedA2[k2], r1);
                }
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }

        /// <summary>
        /// ビット全探索　メソッドバージョン
        /// </summary>
        /// <param name="n"></param>
        /// <returns>含むindexが返ってくる</returns>
        public static int[][] BitSearch(int n)
        {
            int[][] ret = new int[1 << n][];
            for (int bit = 0; bit < (1 << n); ++bit)
            {
                List<int> S = new List<int>();
                for (int i = 0; i < n; i++)
                {
                    if ((bit & (1 << i)) != 0)
                    {
                        S.Add(i);
                    }
                }

                ret[bit] = S.ToArray();
            }
            return ret;
        }

        /// <summary>
        /// 二分探索 vを超える最低
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="a"></param>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int LowerBound<T>(T[] a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }

        /// <summary>
        /// 二分探索 vを超えない最高
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="a"></param>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int UpperBound<T>(T[] a, T v)
        {
            return UpperBound(a, v, Comparer<T>.Default);
        }

        public static int UpperBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res <= 0) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
    }
}



Measured memory_bytes: 270640