#P6078. Candy Jar Distribution

    ID: 19302 Type: Default 1000ms 256MiB

Candy Jar Distribution

Candy Jar Distribution

John has got n jars of candies. The candies in different jars are of different types. The i-th jar contains \(m_i\) candies. He decided to eat some of them: at least \(a\) candies but no more than \(b\) candies in total. However, he is unsure about how many candies to eat and which candy type (jar) to take them from. Your task is to compute the number of ways for John to choose candies such that if he picks \(x_i\) candies from jar \(i\), then \(0 \le x_i \le m_i\) for all \(i\) and \(a \le x_1+x_2+\cdots+x_n \le b\).

inputFormat

The input consists of two lines. The first line contains three integers \(n\), \(a\) and \(b\) separated by spaces. The second line contains \(n\) integers \(m_1, m_2, \dots, m_n\) indicating the number of candies in each jar.

outputFormat

Output a single integer representing the number of ways to choose candies such that the total amount is between \(a\) and \(b\) (inclusive).

sample

2 1 3
1 2
5