Given weights, we have to place all of them on a scale, one after another, in such a way that the right pan is never heavier than the left pan. Please compute the number of ways of doing this.
For example, for and weights , possible solutions are
where means that the weight is placed on the left pan and means that the weight is placed on the right pan. We remark, as it can be seen in the example, that the order in which we place the weights does matter. Hence, and are different solutions.
Input consists of several cases, each with the number of weights followed by different weights, all between 1 and . Assume .
For every case, print the number of correct ways of placing the weights on the scale. This number will never be larger than .
Input
1 20 3 1 2 4 3 6 10 4 8 1 2 3 4 5 6 7 8
Output
1 15 17 2130717