#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m - 1; i++) {
    if (a[i + 1] - a[i] == 1) {
      puts("0");
      return 0;
    }
  }
  ll res = (m + (n - 2 * m - 1)) % 1000000007;
  res *= ((n - 2 * m - 1)) % 1000000007;
  res *= 3;
  res %= 1000000007;
  res /= 8;
  res %= 1000000007;
  cout << res << endl;
  return 0;
}
