#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M + 1);
  bool bb = false;
  int d = 0;
  long long e = 1;
  for (int i = 0; i < M; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < M - 1; i++) {
    if (a.at(i) + 1 == a.at(i + 1)) {
      bb = true;
      break;
    }
  }
  if (M == 1) {
    b.at(0) = a.at(0) - 1;
    b.at(1) = N - a.at(0) - 1;
  } else {
    for (int i = 0; i < M; i++) {
      if (i == 0) {
        b.at(i) = a.at(0) - 1;
      } else if (i == M - 1) {
        b.at(i + 1) = N - a.at(i) - 1;
      } else {
        b.at(i) = a.at(i) - a.at(i - 1) - 2;
      }
    }
  }
  for (int i = 0; i < M + 1; i++) {
    if (b.at(i) == 1) {
      b.at(i) = 1;
    } else {
      d = b.at(i);
      b.at(i) = (d * d - 3 * d + 6) / 2;
    }
  }
  for (int i = 0; i < M + 1; i++) {
    e = e * b.at(i);
  }
  if (bb == true) {
    cout << "0" << endl;
  } else {
    cout << e % 1000000007 << endl;
  }
}
