import sys
n,m= map(int, input().split())
array = list(map(int, input().split()))
if m !=1:
  for j in range(m-1):
    if array[j+1]-array[j] ==1 :
        print(0)
        sys.exit()

count = n -1 - m*3
for i in range(m):
    if array[i]==1:
        count +=1
    elif array[i]==n-1:
        count +=1

print(2**count)