n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
ans = 0

for i in range(m):
    if i == 0:
        j = (a[0]-1)*2 + (n-(a[0]+1)*2
        ans += j
    elif i >= 1 :
        if a[i] - a[i-1] == 1:
            print(0)
            break
        else:
            k = (a[i]-1)*2 + (n-(a[i]+1)*2 
            ans += k
else:
    print(ans % 1000000007)