A Famous Stone Collector#3584

A Famous Stone Collector

15 seconds
32 megabytes
Easy

Mr. B loves to play with colorful stones. There are colors of stones in his collection. Two stones with the same color are indistinguishable. Mr. B would like to select some stones and arrange them in line to form a beautiful pattern. After several arrangements he finds it very hard for him to enumerate all the patterns. So he asks you to write a program to count the number of different possible patterns.

Two patterns are considered different, if and only if they have different number of stones or have different colors on at least one position.

Input

Each test case starts with a line containing an integer indicating the kinds of stones Mr. B has. Following this is a line containing integers - the number of available stones of each color respectively. All the input numbers will be nonnegative and no more than .

Output

For each test case, display a single line containing the case number and the number of different patterns Mr. B can make with these stones, modulo , which is a prime number.

Examples

Example 1

Loading
Loading

Note

In the first case, suppose the colors of the stones Mr. B has are B, G and M, the different patterns Mr. B can form are: B; G; M; BG; BM; GM; GB; MB; MG; BGM; BMG; GBM; GMB; MBG; MGB.