#include <bits/stdc++.h>
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
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 - 1; i++) {
    if (a[i] + 1 == a[i + 1]) {
      cout << 0;
      renzoku = false;
      break;
    }
  }
  ll ppx = (m + (n - 2 * m - 1) * (n - 2 * m - 1) * (3 / 8)) % 1000000007;
  if (renzoku) cout << ppx;
}
