N,M=map(int,input().split())
a=[]
b=[0]*N
for i in range(M):
    a.append(int(input()))
j=0
if a[0]==1:
    b[0]=0
    b[1]=1
elif a[0]==2:
    b[0]=1
    b[1]=1
else:
    b[0]=1
    b[1]=2
for i in range(N-2):
    if j==M-1 or ((i+2)!=a[j] and (i+1)!=a[j]):
        b[i+2]=b[i+1]+b[i]
    if j>0 and a[j]==a[j-1]+1:
        b[N-1]=0
    if j+1<M and a[j+1]==a[j]+1:
        b[N-1]=0
    elif (i+2)==a[j]:
        b[i+2]=b[i]
    elif j+1<M and (i+1)==a[j]:
        j+=1
        b[i+2]=b[i+1]
    elif (i+1)==a[j]:
        b[i+2]=b[i+1]
print(b[N-1]%1000000007,b)