N, M = list(map(int, input().split()))
a = []
b = []

for i in range(M):
    A = int(input())
    a.append(A)

inf = 1000000007

def judge(arr):
    for i in range(1,len(arr)):
        if arr[i-1]+1 == arr[i]:
            return 1
    return 0

if judge(a):
    print(0)
    exit()

S = []


for i in a:
    b.append([i-1,i])
    b.append([i,i+1])

for i in range(1,N):
    if not [i,i+1] in b:
        S.append([i,i+1])

print(2**(len(S)-1)%inf)