import sys
from pprint import pprint

def solve(n, m, a):
    sum = 1
    a_pre = 0
    for a_i in a:
        if a_pre != 0 and a_pre == a_i:
            return 0
        if a_i == 1:
            a_pre = a_i + 1
            continue
        pattern = (a_i - 1 - a_pre - 1)
        #print pattern
        sum *= 2**pattern
        a_pre = a_i + 1
    pattern = (n - a_pre - 1)
    #print pattern
    sum *= 2**pattern

    return sum % 1000000007


if __name__ == '__main__':

    n, m = map(int, sys.stdin.readline().strip().split(" "))
    a = []
    for i in range(m):
        a.append(int(sys.stdin.readline().strip()))
    print solve(n, m, a)