#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e6;
const long long MOD = 1e9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  long long mod = 1e9 + 7;
  long long N, M;
  cin >> N >> M;
  vector<long long> a(M);
  for (int i = 0; i < (int)(M); i++) cin >> a[i];
  vector<long long> steps(N + 1, 0);
  for (int i = 0; i < (int)(M - 1); i++)
    if (a[i] == a[i + 1] - 1) {
      cout << 0 << endl;
      return 0;
    }
  for (int i = 0; i < (int)(M - 1); i++) steps[a[i + 1] - a[i] - 2]++;
  steps[a[0] - 1]++;
  steps[N - a[M - 1] - 1]++;
  COMinit();
  long long ans = 1;
  for (int i = 0; i < (int)(N + 1); i++) {
    if (steps[i] == 0) continue;
    long long two_max = i / 2, way = 0;
    for (int two = 0; two < (int)(two_max + 1); two++) {
      long long one = i - 2 * two;
      way += COM(one + two, two);
      way %= mod;
    }
    for (int j = 0; j < (int)(steps[i]); j++) ans = (ans * way) % mod;
  }
  cout << ans << endl;
  return 0;
}
