N-dimensional plane

4

6 votes
Combinatorics, Basics of Combinatorics, Math, C++
Problem

You are at the origin in the N-dimensional plane and want to go some point in the plane in the minimum number of steps. Formally, with every step you take, you must decrease the distance between you and the end place by one.

If you are provided with the endpoint, calculate the number of different ways you can go to the endpoint mod 109+7.

Input format

  • The first line contains $n$.
  • The second line contains $n$ integers denoting the coordinate of the destination.

Output format

Print the number of ways you can reach the destination mod 109+7.

Constraints

1t50

1n105

It is guaranteed that the minimum distance that will be moved from origin to endpoint will be less than or equal to 2105.

Sample Input
3
2
1 1
3
2 3 1
2
1 2
Sample Output
2
60
3
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

In the first test case you need to move 1 step in the first dimension and 1 step in the second dimension there is 2 ways to obtain that

first way: move in the first dimension then the second dimension

second way: move in second dimension then the first dimension

Editor Image

?