Under construction

Still being built. Things may change

Sweets

Time limit1sMemory limit128 MB

Summary
Count the ways to take up to m_i candies from each of n jars so the total is between a and b, modulo 2004.
Level

Hard8 of 10

Topics
Dynamic programming, Prefix sum, Combinatorics, Math
Solved
No attempts yet

Problem

John has nn jars of candies. Each jar holds a distinct kind of candy (all candies in one jar are of the same kind, and candies from different jars are of different kinds). The ii-th jar contains mim_i candies.

John wants to eat some of his candies — at least aa but no more than bb in total. From each jar he may take any number of candies between 00 and mim_i inclusive. Two ways of eating are different if they differ in the number of candies taken from at least one jar.

Count the number of ways John can choose the candies to eat so that the total eaten is at least aa and at most bb. Since this number can be large, output it modulo 20042004.

Input

The first line contains three integers nn, aa, and bb separated by single spaces (1≤n≤101 \le n \le 10, 0≤a≤b≤1070 \le a \le b \le 10^7). Each of the next nn lines contains one integer; line i+1i+1 contains mim_i, the number of candies in the ii-th jar (0≤mi≤1060 \le m_i \le 10^6).

Output

Let kk be the number of ways John can choose the candies to eat. Output a single integer: k mod 2004k \bmod 2004 (the remainder of kk divided by 20042004).

Hint

In the sample the two jars hold 33 and 55 candies, and the total eaten must satisfy 1≤total≤31 \le \text{total} \le 3. Writing each way as (candies taken from jar 1, candies taken from jar 2), the 99 valid ways are:

(1,0),(2,0),(3,0),(0,1),(0,2),(0,3),(1,1),(1,2),(2,1)(1,0), (2,0), (3,0), (0,1), (0,2), (0,3), (1,1), (1,2), (2,1)

Examples3

  1. Example 1

    Input
    2 1 3
    3
    5
    
    Expected output
    9
    
  2. Example 2

    Input
    1 0 5
    5
    
    Expected output
    6
    
  3. Example 3

    Input
    2 0 1000
    2
    2
    
    Expected output
    9