#P5505. [JSOI2011] 分特产

[JSOI2011] 分特产

Problem Description

JYY led a team to several ACM/ICPC\text{ACM/ICPC} contests and brought back many local specialties, which he wants to distribute to the students in the lab.

JYY wants to know: if these specialties are distributed to nn students, how many different distribution methods are there in total? Of course, JYY does not want any student to feel upset because they did not get any specialties, so each student must receive at least one specialty.

For example, JYY brought 22 bags of twisted dough sticks and 11 bag of buns, and distributes them to students AA and BB. Then there are 44 different distribution methods:

AA: twisted dough stick, BB: twisted dough stick, bun

AA: twisted dough stick, twisted dough stick, BB: bun

AA: bun, BB: twisted dough stick, twisted dough stick

AA: twisted dough stick, bun, BB: twisted dough stick

Input Format

Input testdata:

The first line contains the number of students nn and the number of specialty types mm.

The second line contains mm integers, where each integer represents the quantity of one type of specialty.

n,mn, m do not exceed 10001000, and the quantity of each specialty type does not exceed 10001000.

Output Format

Output one line: the total number of different distribution plans.

Since the result may be extremely large, you only need to output the value of the final result mod 109+7\bmod\ {10^9+7}.

5 4
1 3 3 5
384835

Hint

Translated by ChatGPT 5