(n, m) = map(int, input().split())
a = [-1]
for _ in range(m):
    a.append(int(input()))
a.append(n+1)


def calc_patterns(num):
    if 1 == num:
        return 1
    elif 2 == num:
        return 2
    else:
        return num - 2 + calc_patterns(num-1)


patterns = [0, 1, 2]
for i in range(3, n+1):
    patterns.append(i - 2 + patterns[i-1])


count = 0
for i in range(1, len(a)):
    if a[i] == (a[i-1] + 1):
        print(0)
        exit(0)
    count += patterns[a[i] - 1 - (a[i-1]+1)]
print(count % 1000000007)
