import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def count_combinations(min_val, max_val):
    path_len = max_val - min_val - 2
    if path_len < 2:
        return 1
    twos = path_len // 2
    min_amount = twos + (path_len % 2)
    count = 0
    for i in range(min_amount, path_len + 1):
        count += comb(i, twos)
        twos -= 1
    return count

def conut_paths(a):
    paths = 1
    for i in range(len(a) - 1):
        paths *= count_combinations(a[i], a[i + 1])
    return paths % 1000000007

N, M = map(int, input().split())
A = [int(input()) for i in range(M)]
A.sort()

for i in range(1, M):
    if A[i - 1] + 1 == A[i]:
        print(0)
        exit()

A.insert(0, -1)
A.append(N + 1)
print(A)
print(conut_paths(A))
