#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int tansaku(int now);
int vector_finder(vector<int> vec, int number);
int ans = 1;
vector<int> a(1);
int n, m;
int main() {
  cin >> n >> m;
  a.resize(m);
  int x, one, two, r = 1;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    if (i != 0 && a[i] - 1 == a[i - 1]) {
      ans = 0;
      cout << ans << endl;
      return 0;
    } else if (i != 0) {
      x = a[i] - a[i - 1];
      two = x / 2;
      one = x % 2;
      for (int i = 2; i <= two + one; i++) {
        r *= i;
      }
      ans *= r;
    }
  }
  ans %= mod;
  cout << ans << endl;
}
int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
