N, M = map(int, input().split())
pattern = [2]*N
pattern[-1] = 1

for i in range(M):
    a = int(input())
    if a == 1:
        pattern[a] = 1
        pattern[a-1] -= 1
    else:
        pattern[a] = 1
        pattern[a-1] -= 1
        pattern[a-2] -= 1
CP = 1
print(pattern)
for i in range(N):
    CP *= pattern[i]
print(CP % 1000000007)
