#include <bits/stdc++.h>
using namespace std;
const int N = 1005, mod = 1e9 + 7;
int n, m, cnt, nn;
long long a[N], p, q = 1, fac[N];
bool b[N];
long long power(long long x, int k) {
  long long ans = 1;
  while (k) {
    if (k & 1) ans = (ans * x) % mod;
    x = (x * x) % mod;
    k >>= 1;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % mod;
  nn = n;
  for (int i = 1, x; i <= m; ++i) {
    scanf("%d", &x);
    b[x] = 1;
  }
  long long tmp = 0;
  for (int i = 1; i <= n; ++i)
    if (!b[i])
      ++tmp;
    else if (tmp)
      a[++cnt] = tmp, tmp = 0;
  if (tmp) a[++cnt] = tmp, tmp = 0;
  n = cnt;
  if (!n) {
    printf("1\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    q = q * fac[a[i]] % mod;
    tmp += a[i];
  }
  long long tmp2 = 0;
  if (n == 1 && b[1] && b[nn])
    tmp2 += a[1] - 1;
  else if (n != 1) {
    if (b[1]) tmp2 += a[1] - 1;
    if (b[nn]) tmp2 += a[n] - 1;
  }
  for (int i = 2; i < n; ++i) tmp2 += a[i] - 1;
  printf("%lld\n", fac[tmp] * power(q, mod - 2) % mod * power(2, tmp2) % mod);
  return 0;
}
