#P1680. 奇怪的分组

奇怪的分组

Description

There are NN people in V-shen’s class. dm wants to split them into MM groups. The number of people in the ii-th group must be greater than the given positive integer CiC_i. How many different plans are there? Two plans are considered the same if and only if, for every ii, the sizes of the ii-th group are equal in both plans. Since the answer can be large, output it modulo 109+710^9+7.

Input Format

The first line contains two integers NN and MM. The next MM lines each contain one integer, denoting CiC_i.

Output Format

Output a single line containing one integer — the number of plans modulo 109+710^9+7.

10 3
1
2
3

3

Hint

Sample Explanation: There are three plans, with group sizes (3,3,4)(3, 3, 4), (2,4,4)(2, 4, 4), and (2,3,5)(2, 3, 5).

Constraints:

  • For 30%30\% of the testdata, N,M10N, M \le 10.
  • For 60%60\% of the testdata, N,M1000N, M \le 1000.
  • For 100%100\% of the testdata, 1N,M1061 \le N, M \le 10^6, 1Ci10001 \le C_i \le 1000.

The testdata guarantees that there is at least one valid plan.

Translated by ChatGPT 5