import sys
N, M = map(int, input().split())

a_list = [0] * M

for m in range(M):
    a_list[m] = int(input())

for m in range(M - 1):
    if a_list[m] + 1 == a_list[m + 1]:
        print(0)
        sys.exit()

range_list = [i for i in range(1, N + 1)]
new_list = [0] * (M + 1)

a = 0
if a_list[0] == 1:
    new_list[0] = []
else:
    new_list[0] = [0] + range_list[0: a_list[0] - 1]
new_list[M] = range_list[a_list[M - 1]:]

if M - 1 >= 1:
    for m in range(1, M):
        new_list[m] = range_list[a_list[m - 1]: a_list[m] - 1]

MOD = 1000000007
#print(new_list)
value = 1
for item in new_list:
    if len(item) == 0:
        continue
    else:
        if (len(item) - 1) % 2 == 0:
            value *= (2 ** ((len(item) - 1) // 2)) % MOD
            value %= MOD
        else:
            value *= ((2 ** ((len(item) - 1) // 2)) + 2 ** (((len(item) - 1) // 2) - 1)) % MOD
            value %= MOD

print(value)