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;

}