This page is still under construction.

Parts of this page are still being built. What you see may change.

Actually visible points

Time limit1sMemory limit256 MB

Summary
Count the nondecreasing integer chains ending at the given values with no other chain point on the segment from the origin, modulo 1000000007.
Level

Hard8 of 10

Topics
Number theory, Combinatorics, Dynamic programming
Solved
No attempts yet

Problem

An NN dimensional coordinate system holds several points. They are described by MM natural numbers X1,X2,…,XMX_1, X_2, \dots, X_M, and the set SiS_i described by XiX_i is

Si={(x1,x2,…,xN)∣1≤x1≤x2≤⋯≤xN=Xi}S_i = \{(x_1, x_2, \dots, x_N) \mid 1 \le x_1 \le x_2 \le \dots \le x_N = X_i\}

where x1,x2,…,xNx_1, x_2, \dots, x_N are all natural numbers.

Let S=S1∪S2∪⋯∪SMS = S_1 \cup S_2 \cup \dots \cup S_M. The points that lie in the coordinate system are exactly the points of SS.

Count the points visible from the origin (0,0,…,0)(0, 0, \dots, 0). A point pp is visible when the segment joining the origin and pp contains no point of SS other than pp itself. A lattice coordinate on that segment that does not belong to SS blocks nothing.

Input

The first line contains two natural numbers NN and MM separated by a space. (2≤N≤1000002 \le N \le 100000, 1≤M≤1000001 \le M \le 100000)

Each of the next MM lines contains one natural number XiX_i. (1≤Xi≤1000001 \le X_i \le 100000) The XiX_i are pairwise distinct.

Output

Print the number of points visible from the origin, modulo 10000000071000000007.

Note

For N=2N = 2 and XX equal to 1, 2, 3, 4, the points of SS are (1,1)(1,1), (1,2)(1,2), (2,2)(2,2), (1,3)(1,3), (2,3)(2,3), (3,3)(3,3), (1,4)(1,4), (2,4)(2,4), (3,4)(3,4), (4,4)(4,4). Six of them are visible: (1,1)(1,1), (1,2)(1,2), (1,3)(1,3), (2,3)(2,3), (1,4)(1,4), (3,4)(3,4). The point (4,4)(4,4) is hidden by (3,3)(3,3), which lies on the segment and belongs to SS, and (2,4)(2,4) is hidden by (1,2)(1,2).

With XX equal to 4 alone the answer changes. Then SS is only (1,4)(1,4), (2,4)(2,4), (3,4)(3,4), (4,4)(4,4), and (1,2)(1,2) is missing from SS, so all four points are visible.

Examples2

  1. Example 1

    Input
    2 4
    1
    2
    3
    4
    
    Expected output
    6
    
  2. Example 2

    Input
    2 1
    4
    
    Expected output
    4