#include <bits/stdc++.h>
using namespace std;
long long fact[1001];
long long fpow(int a, int b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = x * y;
      if (x > 1000000007) x %= 1000000007;
    }
    y = y * y;
    if (y > 1000000007) y %= 1000000007;
    b /= 2;
  }
  return x;
}
long long inverse(long long a) { return fpow(a, 1000000007 - 2); }
int main() {
  fact[0] = 1LL;
  for (int i = 1; i <= 1000; i++)
    fact[i] = (fact[i - 1] * ((long long)i)) % 1000000007;
  int n;
  cin >> n;
  int m;
  cin >> m;
  bool arr[n];
  memset(arr, 0, sizeof arr);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    a--;
    arr[a] = 1;
  }
  int dist = 0;
  vector<int> distances;
  int sumDist = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i]) {
      distances.push_back(dist);
      sumDist += dist;
      dist = 0;
    } else
      dist++;
  }
  distances.push_back(dist);
  sumDist += dist;
  long long ans = fact[sumDist];
  for (int i = 0; i < distances.size(); i++)
    ans = (ans * inverse(fact[distances[i]])) % 1000000007;
  for (int i = 1; i + 1 < distances.size(); i++) {
    if (distances[i] > 1) ans = (ans * fpow(2, distances[i] - 1)) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
