#P2371. [国家集训队] 墨墨的等式

[国家集训队] 墨墨的等式

Description

Momo has suddenly become interested in equations. He is studying the condition under which i=1naixi=b\sum_{i=1}^n a_ix_i=b has a non-negative integer solution. He asks you to write a program: given n,a1n,l,rn, a_{1\dots n}, l, r, find how many b[l,r]b \in [l, r] make the equation have a non-negative integer solution.

Input Format

The first line contains three integers n,l,rn,l,r. The second line contains nn integers a1na_{1\dots n}.

Output Format

Output one integer on a single line, indicating how many b[l,r]b \in [l, r] make the equation have a non-negative integer solution.

2 5 10
3 5

5

Hint

For 20%20\% of the testdata, n5n \le 5, r10r \le 10. For 40%40\% of the testdata, n10n \le 10, r106r \le 10^6. For 100%100\% of the testdata, n12n \le 12, 0ai5×1050 \le a_i \le 5\times 10^5, 1lr10121 \le l \le r \le 10^{12}.

Translated by ChatGPT 5