#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL mod = 1e9 + 7;
LL bigmod(LL a, LL b) {
  if (b == 0) return 1;
  LL u = bigmod(a, b / 2);
  u = (u * u) % mod;
  if (b % 2) u = (u * a) % mod;
  return u;
}
LL fact[1005];
LL mul(LL a, LL b) { return ((a % mod) * (b % mod)) % mod; }
signed main() {
  fact[0] = 1;
  for (int i = 1; i < 1005; i++) fact[i] = mul(fact[i - 1], i);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) cin >> a[i];
  sort(a.begin(), a.end());
  LL now = 0;
  now += a[0] - 1;
  now += n - a[m - 1];
  LL ans = 1;
  ans = ans * bigmod(fact[a[0] - 1], mod - 2) % mod;
  ans = ans * bigmod(fact[n - a[m - 1]], mod - 2) % mod;
  for (int i = 1; i < m; i++) {
    if (a[i - 1] + 1 == a[i]) continue;
    int sz = a[i] - a[i - 1] - 1;
    ans = (ans % mod) * bigmod(fact[sz], mod - 2) % mod;
    ans = (ans * bigmod(2LL, sz - 1)) % mod;
    now += sz;
  }
  ans = (ans * fact[now]) % mod;
  cout << ans << "\n";
}
