#include <bits/stdc++.h>
using namespace std;
long long MOD = 10e8 + 7;
long long facctorialMethod(int k) {
  long long sum = 1;
  for (int i = 1; i <= k; ++i) {
    sum = ((i % MOD) * (sum % MOD)) % MOD;
  }
  if (k == 0) return 1;
  return sum;
}
int main() {
  int n, m;
  long long ans = 1;
  cin >> n >> m;
  int str[m];
  for (int(i) = 0; (i) < (m); (i)++) {
    cin >> str[i];
  }
  if (m > 1) {
    for (int(i) = 0; (i) < (m); (i)++) {
      if (str[i] + 1 == str[i + 1]) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  if (m > 1) {
    for (int i = 0; i <= m - 2; i++) {
      ans = ((facctorialMethod(str[i + 1] - 1 - str[i]) % MOD) * (ans % MOD)) %
            MOD;
    }
  }
  ans = ((facctorialMethod(str[0] - 1) % MOD) * (ans % MOD)) % MOD;
  ans = ((facctorialMethod(n - str[m - 1] - 1) % MOD) * (ans % MOD)) % MOD;
  cout << ans % MOD << endl;
  return 0;
}
