#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int NMAX = 1000;
int n, m, firston = NMAX + 1, laston = 0;
bool arr[NMAX + 1];
long long fac[NMAX + 1];
void buildFac() {
  long long f = 1;
  fac[0] = 1;
  for (long long i = 1; i <= NMAX; i++) {
    f = (f * i) % MOD;
    fac[i] = f;
  }
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x % MOD;
  while (y > 0) {
    if (y & 1) res = (res * x) % MOD;
    y = y >> 1;
    x = (x * x) % MOD;
  }
  return res;
}
long long modInv(long long n) { return power(n, MOD - 2); }
void solve() {
  memset(arr, false, sizeof arr);
  cin >> n >> m;
  if (n == m) {
    cout << 1 << '\n';
    return;
  }
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    --tmp;
    arr[tmp] = true;
    firston = min(firston, tmp);
    laston = max(laston, tmp);
  }
  vector<int> gaps;
  int gap = 0;
  for (long long i = firston; i <= laston; i++) {
    if (arr[i]) {
      if (gap > 1) gaps.push_back(gap);
      gap = 0;
    } else
      gap++;
  }
  long long gapsum = 0;
  for (int i = 0; i < (int)(gaps.size()); i++) gapsum += (gaps[i] - 1);
  long long ans = fac[n - m];
  ans = (ans * modInv(fac[n - laston - 1])) % MOD;
  ans = (ans * modInv(fac[firston])) % MOD;
  for (auto it : gaps) ans = (ans * modInv(fac[it])) % MOD;
  ans = (ans * power(2, gapsum)) % MOD;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  buildFac();
  solve();
  return 0;
}
