Medium Math > Combinations and Permutations

**Petr** and some of his friends went to a shop to buy some balls. They are **N** people. There are actually **N** different colors of ball. The number of balls of ith color is **Ci**. Now Petr wants to know in how many ways they can buy all balls of the shop so that, everyone have at least one ball of all different color. You have to find the answer modulo **1000000007**. Input: ------ Input starts with an integer **T** (1<=T<=100) denoting the number of test cases. Each case starts with a positive integer N (1<=N<=1000), denoting the number of people and the number of color. In the next line there are **N** integers ( Ci ) denoting the number of balls of ith color ( 0<=Ci<=2000). Output: ------- Output T lines, with case number at the beginning and then the answer. See sample input output for more details. Sample Input ------------ 2 3 3 3 3 2 3 2 Sample Output ------------- Case 1: 1 Case 2: 2

Al Mamun Akash