#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
const int M = 1e9 + 7;
long long a[N];
vector<long long> v;
long long fact[N];
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % M;
    a = (a * a) % M;
    b /= 2;
  }
  return ans;
}
long long calc(int n, int m) {
  return (fact[n + m] * power((fact[m] * fact[n]) % M, M - 2)) % M;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, x, cnt = 0;
  cin >> n >> m;
  fact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i) % M;
  for (int i = 0; i < m; i++) {
    cin >> x;
    a[x] = 1;
  }
  for (int i = 1; i <= n;) {
    while (a[i] == 0 && i <= n) {
      cnt++;
      i++;
    }
    while (a[i] == 1 && i <= n) {
      i++;
    }
    if (cnt > 0) v.push_back(cnt);
    cnt = 0;
  }
  long long t = 0;
  long long ans = 1;
  if (v.size() == 1) {
    if (a[1] == 1 && a[n] == 1) {
      ans = (ans * power(2, v[0] - 1)) % M;
    }
  }
  if (v.size() > 1) {
    if (a[1] == 1) ans = (ans * power(2, v[0] - 1)) % M;
  }
  for (int i = 1; i < v.size(); i++) {
    t += v[i - 1];
    if (i == v.size() - 1) {
      if (a[n] == 1) ans = (ans * power(2, v[i] - 1)) % M;
    } else
      ans = (ans * power(2, v[i] - 1)) % M;
    ans = (ans * calc(t, v[i])) % M;
  }
  cout << ans;
}
