# -*- coding: utf-8 -*-
n, m = map(int, input().split())
BIGNUM = 1000000007

zero_flag = False

last_ana = int(input())
blocks = [last_ana]

for _ in range(1, m):
    ana = int(input())
    blocks.append(ana - last_ana - 1)
    last_ana = ana

blocks.append(n - last_ana)

if 0 in blocks:
    ans = 0
else:
    ans = 1
    for num in blocks:
        if num == 1:
            continue
        k = num // 2
        m = num % 2
        cases = 3 * k - 2 + m
        ans *= cases
        # if ans >= BIGNUM:
        #     ans %= BIGNUM

print(ans)