#include <bits/stdc++.h>
using namespace std;
long long int mod = (long long int)1e9 + 7ll;
long long int modexp(long long int x, long long int y) {
  long long int ans = 1ll;
  while (y > 0) {
    if (y & 1) ans = (ans * x) % mod;
    x = (x * x) % mod;
    y = y >> 1;
  }
  return ans;
}
long long int modinv(long long int x) { return modexp(x, mod - 2); }
long long int fac(long long int x) {
  if (x == 0ll) return 1ll;
  return (x * fac(x - 1)) % mod;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1, 0);
  for (int i = 0; i < (int)(m); ++i) {
    int x;
    cin >> x;
    v[x] = 1;
  }
  vector<int> a;
  int l;
  for (int i = 1; i <= (int)(n); ++i) {
    if (v[i] == 1) {
      l = i;
      int j = i - 1;
      while (j >= 1 && v[j] != 1) j--;
      a.push_back(i - j - 1);
    }
  }
  a.push_back(n - l);
  long long int ans = fac(n - m);
  for (int i = 0; i < a.size(); i++) {
    ans = (ans * modinv(fac(a[i]))) % mod;
  }
  for (int i = 1; i < a.size() - 1; i++) {
    ans = (ans * modexp(2ll, a[i] - 1)) % mod;
  }
  cout << ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
