#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
int GCD(int a, int b) {
    return b ? GCD(b, a%b) : a;
}
//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

using ll = long long;
using namespace std;
int main() {
    int n, m;
    int a[110000];
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> a[i];
    bool renzoku = true;
    
    for (int i = 0; i < m; i++) {
        if (a[i] == a[i+1]+1) {
            renzoku = false;
                break;
        }
    }
    ll ppx = (m+((n - 3m)*(n - 3*m) *3/ 8)) % 1000000007;
    if(renzoku)cout << ppx;
    else cout << 0;

}