import math
n, m = map(int, input().split(' '))
a = []
for _ in range(m):
  a.append(int(input()))
ans = -1

block = []
if m == 0:
  block.append(n)
else:
  block.append(a[0]-1)
  for i in range(1, m):
    d = a[i] - a[i-1] - 1
    if d == 0:
      ans = 0
      break
    else:
      block.append(d)
  block.append(n - a[-1]-1)

print(block,ans)
if ans != 0:
  b_p = [0]*len(block)
  for i in range(len(block)):
    b_n = block[i]
    if b_n == 0:
      b_p[i] = 1
      continue
    for t in range(math.ceil(b_n/2)-1, b_n):
      b_p[i] += math.factorial(b_n-1) // (math.factorial((b_n-1) - t) * math.factorial(t))
  
  ans = 1
  for b in b_p:
    if b != 0:
      ans *= b

print(ans % (10**9+7))