Solar flare

0

0 votes
Combinatorics, Easy
Problem

A \( solar flare \) is a phenomenon where the sun suddenly releases a great amount of solar radiation, much more than normal. In total, there are n possible wavelengths of radiations and there are m different types of radiation . The total effect of \( solar flare \) is total number of distinct arrangement of wavelength of radiations. As the total number can be large , you have to report the answer mod \(10^{9}+7\) .

Arrangement \(A_{1},A_{2}......A_{n} \) and \(B_{1},B_{2}......B_{n} \) is said to be different if for any i, \(1 \le i \le n \) , \(A_{i}\) \(\neq\) \(B_{i}\)

Input :

First line contains n and m

Next line contains an array of M elements, denoting number of radiations of \(i^{th}\) type

Output :

Output Number of distinct arrangements modulo \(10^{9}+7\)

Constraints

\(1 \le n,m\le 10^{6}\)

\( 0 \le A_{i} \le 10^{6} \)

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

The possible arrangement can be

  1. 122

  2. 212

  3. 221

Editor Image

?