law = 10 ** 9 + 7

def fibo(N):
    if (N <= 1):
        return N

    return 2 ** (N - 3) + 1

def main():
    N, M = map(int, input().split())

    ans = 1
    b = -1
    for _ in range(M):
        a = int(input())

        if (a > 1):
            ans = (ans * fibo(a - b - 1)) % law
        b = a

    if (a < N - 1):
        ans = (ans * fibo(N + 1 - b - 1)) % law

    return ans


if __name__ == "__main__":
    print(main())
        
