n, m = map(int, input().split())
a = []
ans = 1
for _ in range(m):
    a.append(int(input()))
mod = 10**9 + 7
p = 0
for i in range(m):
    print(p)
    if i == m-1:
        ans *= n - a[i] - 1
        # print('Y')
        break
    if a[i] == 1:
        if a[i+1] == 2:
            ans *= 0
        else:
            pass
    else:
        if a[i] == a[i+1] - 1:
            ans *= 0
        else:
            ans *= a[i] - p - 1
            p = a[i]

print(ans % mod)