N, M=map(int, input().split())
a=[int(input()) for _ in range(M)]

def func(x):
    if x==0:
        return 1
    elif x==-1:
        return 0
    else:
        return 2**(x-1)

s=func(a[0]-1)
for i in range(0, M-1):
    s*=func(a[i+1]-a[i]-2)
s*=func(N-a[M-1]-1)
print(s%1000000007)
         
    
