n, m = map(int, input().split())
s=0
f=0
if m!=0:
    for i in range(m):
        a = int(input())
        if a==f+1 and a!=1:
            s=0
            f=-1
            break
        s+=a-f-1
        f=a

if f!=-1:
    s+=n-f-1
    s%=1000000007
print(s)