#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000;
int c[MAXN][MAXN];
const int MOD = 1e9 + 7;
int two[MAXN];
int main() {
  for (int i = 0; i < MAXN; i++) {
    c[i][i] = 1;
    c[i][0] = 1;
  }
  for (int i = 1; i < MAXN; i++) {
    for (int j = 1; j < i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
    }
  }
  two[0] = 1;
  for (int i = 1; i < MAXN; i++) {
    two[i] = (two[i - 1] * 2) % MOD;
  }
  int n, m;
  cin >> n >> m;
  vector<bool> used(n + 2);
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    used[x] = true;
  }
  used[n + 1] = true;
  int start = 0;
  bool ok = true;
  vector<pair<int, int>> segments;
  for (int i = 1; i <= n + 1; i++) {
    if (used[i]) {
      if (ok == false) {
        segments.emplace_back(start, i - 1);
        ok = true;
      }
    }
    if (!used[i]) {
      if (ok == true) {
        start = i;
        ok = false;
      }
    }
  }
  int total = 0;
  int ans = 1;
  for (auto segment : segments) {
    total += segment.second - segment.first + 1;
  }
  for (auto segment : segments) {
    int length = segment.second - segment.first + 1;
    if (segment.first == 1 || segment.second == n) {
      ans = (long long)ans * c[total][length] % MOD;
    } else {
      ans = (long long)ans * c[total][length] % MOD *
            (long long)two[length - 1] % MOD;
    }
    total -= length;
  }
  cout << ans;
  return 0;
}
