n,m = map(int,input().split())
a = list(int(input()) for hoge in range(m))
dan = [a[0]]
ans = 1
for i in range(m-1):
         if (a[i+1]-(a[i]+1)) == 0:
                  print(0)
                  exit()
         dan.append(a[i+1]-(a[i]+1))
dan.append(n-(a[m-1]))
for j in range (len(dan)):
         ans *= ((2 ** (dan[j] //2)))
print(ans%((10 ** 9) +7))

