# C - Typical Stairs
N,M = map(int, input().split())
a = [int(input()) for i in range(M)]
tmp0 = 1
tmp1 = 1
#穴がある場合の場合わけ
if len(a) == 1:
    tmp = 2*3
else:
    for i in range(1,M):
        if a[i] == a[i-1]+1:
            print(0)
            exit()
        elif a[i] == 1 or a[i] == N-1:
            tmp0 *= 2
        elif a[i] == a[i-1]+2:
            tmp0 *= 2*2
        else:
            tmp1 *= 2*3
    tmp = tmp0 + tmp1

ans = int(2**(N+1-2)/(tmp))
print(ans % (10**9+7))