#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int N = n - m + 1;
  vector<vector<long long>> pascal(N);
  for (int i = 0; i < N; ++i) pascal[i].resize(i + 1);
  pascal[0][0] = 1;
  for (int i = 1; i < N; ++i) {
    pascal[i][0] = pascal[i][i] = 1;
    for (int j = 1; j < i; ++j)
      pascal[i][j] = (pascal[i - 1][j - 1] + pascal[i - 1][j]) % mod;
  }
  vector<long long> pow2(n + 1);
  pow2[0] = 1;
  for (int i = 1; i <= n; ++i) pow2[i] = 2 * pow2[i - 1] % mod;
  vector<int> lights(m);
  for (int &light : lights) cin >> light;
  sort(lights.begin(), lights.end());
  vector<int> darkness(m + 1);
  darkness[0] = lights[0] - 1;
  for (int i = 1; i < m; ++i) darkness[i] = lights[i] - lights[i - 1] - 1;
  darkness[m] = n - lights[m - 1];
  long long ans = 1;
  int A = n - m;
  for (int i = 0; i <= m; ++i) {
    ans = ans * pascal[A][darkness[i]] % mod;
    A -= darkness[i];
  }
  for (int i = 1; i < m; ++i)
    ans = ans * pow2[darkness[i] > 0 ? darkness[i] - 1 : 0] % mod;
  cout << ans;
  return 0;
}
