#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
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(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long calcPattern(int a) {
  long long res = 0;
  for (int i = 0; i <= (a + 1) / 2; i++) {
    res += COM(a - i, i) % MOD;
    res %= MOD;
  }
  cout << a << " " << res << endl;
  return res % MOD;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, M;
  cin >> N >> M;
  vector<int> broken(M);
  COMinit();
  for (int i = 0; i < M; i++) {
    cin >> broken.at(i);
  }
  for (int i = 0; i < M - 1; i++) {
    if (broken.at(i) + 1 == broken.at(i + 1)) {
      cout << 0 << endl;
      return 0;
    }
  }
  vector<int> stairs;
  stairs.push_back(broken.at(0) - 0 - 1);
  for (int i = 0; i < M - 1; i++) {
    stairs.push_back(broken.at(i + 1) - broken.at(i) - 2);
  }
  stairs.push_back(N - broken.at(M - 1) - 1);
  long long ans = 1;
  for (int i = 0; i < stairs.size(); i++) {
    ans *= calcPattern(stairs.at(i)) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
