#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1LL;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
long long inv(long long n) { return power(n, 1000000007 - 2) % 1000000007; }
long long f[2005], fact[2005], fin[2005];
long long nc(long long n, long long r) {
  return (fact[n] * fin[r]) % 1000000007 * fin[n - r] % 1000000007;
}
void solve() {
  long long i;
  f[1] = 1;
  fact[0] = 1;
  for (i = 1; i <= 1e3; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= 1000000007;
  }
  for (i = 0; i <= 1e3; i++) fin[i] = inv(fact[i]);
  for (i = 2; i <= 1e3; i++) {
    f[i] = 2 * f[i - 1];
    f[i] %= 1000000007;
  }
  vector<long long> v;
  long long x, n, m;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  long long sum = 0;
  sum += v[0] - 1;
  sum += n - v[m - 1];
  for (i = 1; i < m; i++) sum += v[i] - v[i - 1] - 1;
  long long ans = 1;
  ans *= nc(sum, v[0] - 1);
  sum -= (v[0] - 1);
  ans %= 1000000007;
  ans *= nc(sum, n - v[m - 1]);
  sum -= (n - v[m - 1]);
  ans %= 1000000007;
  for (i = 1; i < m; i++) {
    long long d = v[i] - v[i - 1] - 1;
    if (d) {
      ans *= (f[d] * nc(sum, d)) % 1000000007;
      sum -= d;
      ans %= 1000000007;
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  long long t = 1;
  while (t--) {
    solve();
  }
}
