Walking in higher dimensions<Amex CodeStreet'19 - Coding Event>

You are placed in a \(k-dimensional\) room rather than 3-dimensional room.
Currently, you are positioned at \(\underbrace{(1, 1, 1, \dots , 1)}_\text{k-1's}\). The exit to the room is located at \((x_1, x_2, \dots, x_k)\). There is a strange restriction on movement though, at each step, you can only move in such a way that you increase only one of the k coordinates by one.
For example, from your initial position, you have k choices, you can either go to \((2, 1, 1, \dots, 1)\), \((1, 2, 1, \dots 1)\), \((1, 1, 2, \dots, 1)\) and so on.

Given the coordinates of the exit, you are tasked with finding the number of ways to reach the exit from your initial position as per the restriction.

INPUT

First line contains k - the dimension of the room.

Next line contains k space separated integers where ith integer denotes \(x_i\), the ith coordinate of the exit.

OUTPUT

A single integer denoting the number of ways to reach the exit. Since the answer can be large, output it modulo \(10^9+7\).

CONSTRAINTS

  • \(1 \leq k \leq 10^5\)
  • \(1 \leq x_i \leq 10^2\)

Sample Input
(Plaintext Link)
2
5 4
Sample Output
(Plaintext Link)
35

Time Limit: 5.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Score is assigned if any testcase passes.
Allowed languages: C, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java 8, JavaScript(Node.js), Julia, Kotlin, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic
Login/Signup to Run Your Code You must save any code that is already written. After you login, we will automatically save your code.

Initializing Code Editor...
Notifications
View All Notifications

?