n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
b=a[0]-1
c=b//2+1
ans=c
if len(a)<=1:
    b=n-a[0]
    c=b//2+1
    ans=ans*c
    print(ans%1000000007)
else:    
    for j in range(len(a)-1):
        if a[j]+1==a[j+1]:
            print(0)
            exit()
        else:
            b=a[j+1]-a[j]
            c=b//2+1
            ans=ans*c
    print(ans%1000000007)