def move(now, goal, m):
    global rlt
    if m==goal:
        rlt += 1
        return

    if m>goal: return

    move(m, goal, m+1)
    move(m, goal, m+2)


N, M = map(int, input().split())

A = [int(input()) for i in range(M)]

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

ans = 0

m = []
now = 0
rlt = 0
for a in A:
    move(now, a-1, now+1)
    move(now, a-1, now+2)
    m.append(rlt)
    rlt = 0

now = A[len(A)-1]+1
move(now, N, now+1)
move(now, N, now+2)
m.append(rlt)

ans = 1

for i in m:
    ans *= i

print(ans%1000000007)

