Solar flare

0

0 votes
Combinatorics, Easy
Problem

A solarflare 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 solarflare is total number of distinct arrangement of wavelength of radiations. As the total number can be large , you have to report the answer mod 109+7 .

Arrangement A1,A2......An and B1,B2......Bn is said to be different if for any i, 1in , Ai Bi

Input :

First line contains n and m

Next line contains an array of M elements, denoting number of radiations of ith type

Output :

Output Number of distinct arrangements modulo 109+7

Constraints

1n,m106

0Ai106

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

The possible arrangement can be

  1. 122

  2. 212

  3. 221

Editor Image

?